Beispiel #1
0
  // 删除一个表
  public void dropTable(String table) {

    try {
      db.execSQL("drop table if exists " + table);

    } catch (SQLException e) {
      Toast.makeText(mCtx, "数据表删除失败", Toast.LENGTH_LONG).show();
    }
  }
Beispiel #2
0
 public void onPressClear(View view) {
   // Do something in response to button
   DataBaseHelper databasehelper = new DataBaseHelper(this);
   SQLiteDatabase db = databasehelper.getWritableDatabase();
   if (db != null) {
     // Se elimina la versión anterior de la tabla
     db.execSQL("DROP TABLE IF EXISTS " + databasehelper.TABLA);
     // Se utiliza para poder crear la nueva base de datos
     databasehelper.onCreate(db);
   }
 }
 public void wipeTable(SQLiteDatabase db) {
   for (String cmd : DROP_TABLE) {
     db.execSQL(cmd);
   }
   onCreate(db);
 }
 @Override
 public void onCreate(SQLiteDatabase db) {
   for (String cmd : CREATE_TABLE) {
     db.execSQL(cmd);
   }
 }
Beispiel #5
0
 public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
   db.execSQL("DROP TABLE IF EXISTS contact");
   onCreate(db);
 }
Beispiel #6
0
 public void onCreate(SQLiteDatabase db) {
   db.execSQL(
       "CREATE TABLE contact ( _id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT, tel TEXT);");
 }
Beispiel #7
0
 public void createTable(String sql) {
   db.execSQL(sql); // 执行有更改的sql语句
 }
Beispiel #8
0
 @Override
 public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
   db.execSQL("DELETE FROM Topico");
   db.execSQL("DELETE FROM Categoria");
 }
Beispiel #9
0
 @Override
 public void onCreate(SQLiteDatabase db) {
   db.execSQL(ScriptSQL.getCreateCategoria());
   db.execSQL(ScriptSQL.getCreateTopico());
 }