예제 #1
0
 @Override
 public void onCreate(SQLiteDatabase db) {
   for (String table : _builder.getTables()) {
     String sqlStr = null;
     try {
       sqlStr = _builder.getSQLCreate(table);
     } catch (DataAccessException e) {
       EvtLog.e(this.getClass().getName(), e);
     }
     if (sqlStr != null) db.execSQL(sqlStr);
   }
   db.setVersion(_version);
 }
예제 #2
0
 @Override
 public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
   ArrayList<String> scripts = databaseUpgrade(oldVersion, newVersion);
   if (scripts == null || scripts.size() == 0) {
     for (String table : _builder.getTables()) {
       String sqlStr = _builder.getSQLDrop(table);
       db.execSQL(sqlStr);
     }
     onCreate(db);
   } else {
     for (int i = 0; i < scripts.size(); ++i) {
       String sql = scripts.get(i);
       if (!(sql.trim().equals("") || sql.trim().startsWith("--"))) {
         db.execSQL(scripts.get(i));
       }
     }
   }
 }