/** * Query. * * @param db * the db * @param conditions * the conditions * @param type * the type * @param listener * the listener */ static void query(SQLiteDatabase db, String conditions, QueryType type, OnResultListener listener) { String query = String.format( "SELECT name, sql FROM sqlite_master WHERE type='%s'and name!='sqlite_sequence' and name!='android_metadata'%s", type.toString().toLowerCase(), StringUtils.hasText(conditions) ? " AND " + conditions : ""); try (Cursor cursor = db.rawQuery(query, null)) { if (cursor.moveToFirst()) { int index0 = cursor.getColumnIndex("name"); int index1 = cursor.getColumnIndex("sql"); do { listener.onRow(db, cursor.getString(index0), cursor.getString(index1)); } while (cursor.moveToNext()); } } }
/** * Query. * * @param db * the db * @param conditions * the conditions * @param type * the type * @param listener * the listener */ static void query(SQLiteDatabase db, String conditions, QueryType type, OnResultListener listener) { String query = String.format( "SELECT name, sql FROM sqlite_master WHERE type='%s'and name!='sqlite_sequence' and name!='android_metadata'%s", type.toString().toLowerCase(), StringUtils.hasText(conditions) ? " AND " + conditions : ""); try (Cursor cursor = db.rawQuery(query, null)) { if (cursor.moveToFirst()) { int index0 = cursor.getColumnIndex("name"); int index1 = cursor.getColumnIndex("sql"); do { listener.onRow(db, cursor.getString(index0), cursor.getString(index1)); } while (cursor.moveToNext()); } } }
@Override public void onRow(SQLiteDatabase db, String name, String sql) { String drop = "DROP " + type.toString().toUpperCase() + " " + name; Logger.info(drop); db.execSQL(drop); } });
@Override public void onRow(SQLiteDatabase db, String name, String sql) { String drop = "DROP " + type.toString().toUpperCase() + " " + name; Logger.info(drop); db.execSQL(drop); } });
@Override public void onRow(SQLiteDatabase db, String name, String sql) { String drop = "DROP " + type.toString().toUpperCase() + " " + name; Logger.info(drop); db.execSQL(drop); } });