/** * Add to all schema's table a specifix prefix. * * @param db * the db * @param prefix * the prefix */ public static void renameAllTablesWithPrefix(SQLiteDatabase db, final String prefix) { Logger.info("MASSIVE TABLE RENAME OPERATION: ADD PREFIX " + prefix); query(db, null, QueryType.TABLE, new OnResultListener() { @Override public void onRow(SQLiteDatabase db, String name, String sql) { sql = String.format("ALTER TABLE %s RENAME TO %s%s;", name, prefix, name); Logger.info(sql); db.execSQL(sql); } }); }
/** * Drop all entity of particular type (table or index). If prefix is * specified, the drop operation is applied only to entity with prefix. * * @param db * the db * @param type * the type * @param prefix * the prefix */ private static void drop(SQLiteDatabase db, final QueryType type, String prefix) { String dropSQL = StringUtils.hasText(prefix) ? "name like '" + prefix + "' || '%'" : null; query(db, dropSQL, type, new OnResultListener() { @Override public void onRow(SQLiteDatabase db, String name, String sql) { String drop = "DROP " + type.toString().toUpperCase() + " " + name; Logger.info(drop); db.execSQL(drop); } }); }