コード例 #1
0
  @Override
  public void onCreate(SQLiteDatabase database) {

    try {
      database.beginTransaction();

      TableBuilder builder = new TableBuilder(ApplicationRecord.class);
      database.execSQL(builder.getTableCreateString());

      builder = new TableBuilder(AndroidSharedKeyRecord.class);
      database.execSQL(builder.getTableCreateString());

      builder = new TableBuilder(AndroidLogEntry.STORAGE_KEY);
      builder.addData(new AndroidLogEntry());
      database.execSQL(builder.getTableCreateString());

      DbUtil.createNumbersTable(database);

      database.setVersion(GLOBAL_DB_VERSION);

      database.setTransactionSuccessful();
    } finally {
      database.endTransaction();
    }
  }
コード例 #2
0
  @Override
  public void onCreate(SQLiteDatabase db) {

    // creating required tables
    db.execSQL(AnswerAccess.CREATE_TABLE);
    db.execSQL(AnswerTypeAccess.CREATE_TABLE);
    db.execSQL(QuestionAccess.CREATE_TABLE);
    db.execSQL(SurveyResponseAccess.CREATE_TABLE);
  }
コード例 #3
0
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    // create new tables
    db.execSQL(DROP_TABLE_PRE_FIX + " " + AnswerAccess.TABLE_NAME);
    db.execSQL(DROP_TABLE_PRE_FIX + " " + AnswerTypeAccess.TABLE_NAME);
    db.execSQL(DROP_TABLE_PRE_FIX + " " + QuestionAccess.TABLE_NAME);
    db.execSQL(DROP_TABLE_PRE_FIX + " " + SurveyResponseAccess.TABLE_NAME);
    onCreate(db);
  }
  @Override
  public boolean execute(SQLiteDatabase database) {

    database.execSQL("create table t1(a INTEGER, b INTEGER);");
    database.execSQL("insert into t1(a,b) values(123, 456);");
    Cursor cursor = database.rawQuery("select * from t1;", new String[] {});
    if (cursor != null) {
      cursor.moveToFirst();
      cursor.copyStringToBuffer(1, charArrayBuffer);
      String actualValue = new String(charArrayBuffer.data, 0, charArrayBuffer.sizeCopied);
      return "456".equals(actualValue);
    }
    return false;
  }
コード例 #5
0
 public static int executeSqlStatements(SQLiteDatabase db, String[] statements) {
   int count = 0;
   for (String line : statements) {
     line = line.trim();
     if (line.length() > 0) {
       db.execSQL(line);
       count++;
     }
   }
   return count;
 }
コード例 #6
0
 @Override
 public void onCreate(SQLiteDatabase db) {
   String sql =
       "create table " + TABLE + "( " + ALIAS + " text not null, " + KEY_DATA + " blob not null);";
   db.execSQL(sql);
 }
コード例 #7
0
 public static void vacuum(SQLiteDatabase db) {
   db.execSQL("VACUUM");
 }
コード例 #8
0
 @Override
 protected void onCreate(SQLiteDatabase database) {
   database.execSQL(TIMELINEEVENT_SQL);
   database.execSQL(TIMELINEVENT_CASEID_INDEX_SQL);
 }