예제 #1
0
  private void executeLegacySqlScript(SQLiteDatabase db, InputStream stream) throws IOException {

    InputStreamReader reader = null;
    BufferedReader buffer = null;

    try {
      reader = new InputStreamReader(stream);
      buffer = new BufferedReader(reader);
      String line = null;

      while ((line = buffer.readLine()) != null) {
        line = line.replace(";", "").trim();
        if (!TextUtils.isEmpty(line)) {
          db.execSQL(line);
        }
      }

    } finally {
      IOUtils.closeQuietly(buffer);
      IOUtils.closeQuietly(reader);
    }
  }
예제 #2
0
  private void executeSqlScript(SQLiteDatabase db, String file) {

    InputStream stream = null;

    try {
      stream = Cache.getContext().getAssets().open(MIGRATION_PATH + "/" + file);

      if (Configuration.SQL_PARSER_DELIMITED.equalsIgnoreCase(mSqlParser)) {
        executeDelimitedSqlScript(db, stream);

      } else {
        executeLegacySqlScript(db, stream);
      }

    } catch (IOException e) {
      Log.e("Failed to execute " + file, e);

    } finally {
      IOUtils.closeQuietly(stream);
    }
  }