Reads the view information from the given database. @param database The database to read the information from. @param viewName The view name. @return A ViewInfo containing the schema information for the provided view name.
(SupportSQLiteDatabase database, String viewName)
| 80 | * @return A ViewInfo containing the schema information for the provided view name. |
| 81 | */ |
| 82 | @SuppressWarnings("SameParameterValue") |
| 83 | public static ViewInfo read(SupportSQLiteDatabase database, String viewName) { |
| 84 | Cursor cursor = database.query("SELECT name, sql FROM sqlite_master " |
| 85 | + "WHERE type = 'view' AND name = '" + viewName + "'"); |
| 86 | //noinspection TryFinallyCanBeTryWithResources |
| 87 | try { |
| 88 | if (cursor.moveToFirst()) { |
| 89 | return new ViewInfo(cursor.getString(0), cursor.getString(1)); |
| 90 | } else { |
| 91 | return new ViewInfo(viewName, null); |
| 92 | } |
| 93 | } finally { |
| 94 | cursor.close(); |
| 95 | } |
| 96 | } |
| 97 | } |
no test coverage detected