/** * Execute SQL. * * @param database * the database * @param commands * the commands */ public static void executeSQL(final SQLiteDatabase database, List<String> commands) { for (String command : commands) { executeSQL(database, command); } // commands.forEach(command -> { // executeSQL(database, command); // }); }
/** * Execute SQL. * * @param database * the database * @param fileInputStream * the file input stream */ public static void executeSQL(final SQLiteDatabase database, InputStream fileInputStream) { List<String> commands = readSQLFromFile(fileInputStream); executeSQL(database, commands); }
@Override public void onCreate(SQLiteDatabase database) { if (firstSchemaDefinitionInputStream != null) { Logger.info("Load DDL from input stream"); SQLiteTestUtils.executeSQL(database, firstSchemaDefinitionInputStream); } else { Logger.info("Load DDL from resourceId"); SQLiteTestUtils.executeSQL(database, context, firstSchemaDefinitionResourceId); } } };
/** * Execute SQL contained in raw resource. * * @param database * the database * @param context * the context * @param rawResourceId * the raw resource id */ public static void executeSQL(final SQLiteDatabase database, Context context, int rawResourceId) { String[] c = IOUtils.readTextFile(context, rawResourceId).split(";"); List<String> commands = Arrays.asList(c); executeSQL(database, commands); }