/** * Read SQL from file. * * @param fileName * the file name * @return the list */ public static List<String> readSQLFromFile(String fileName) { try { return readSQLFromFile(new FileInputStream(fileName)); } catch (FileNotFoundException e) { e.printStackTrace(); return null; } }
/** * 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); }
/** * Execute SQL from file. * * @param database the database * @param fileName the sql definition file */ public static void executeSQLFromFile(SQLiteDatabase database, String fileName) { List<String> executionList = readSQLFromFile(fileName); for (String item : executionList) { Logger.info(item); database.execSQL(item); } }