/** * 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; } }
/** * 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. * * @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 execute(SQLiteDatabase database, int previuosVersion, int currentVersion) { List<String> executionList=null; if (inputStream==null) { File f = new File(schemaDefinitionFile); executionList = SQLiteUpdateTaskHelper.readSQLFromFile(schemaDefinitionFile); Logger.info("Load DDL from " + f.getAbsolutePath()); } else { executionList = SQLiteUpdateTaskHelper.readSQLFromFile(inputStream); Logger.info("Load DDL from stream"); } for (String item : executionList) { Logger.info(item); database.execSQL(item); } }
@Override public void execute(SQLiteDatabase database, int previuosVersion, int currentVersion) { List<String> executionList=null; if (inputStream==null) { File f = new File(schemaDefinitionFile); executionList = SQLiteUpdateTaskHelper.readSQLFromFile(schemaDefinitionFile); Logger.info("Load DDL from " + f.getAbsolutePath()); } else { executionList = SQLiteUpdateTaskHelper.readSQLFromFile(inputStream); Logger.info("Load DDL from stream"); } for (String item : executionList) { Logger.info(item); database.execSQL(item); } }