// 删除一个表 public void dropTable(String table) { try { db.execSQL("drop table if exists " + table); } catch (SQLException e) { Toast.makeText(mCtx, "数据表删除失败", Toast.LENGTH_LONG).show(); } }
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); } }
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS contact"); onCreate(db); }
public void onCreate(SQLiteDatabase db) { db.execSQL( "CREATE TABLE contact ( _id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT, tel TEXT);"); }
public void createTable(String sql) { db.execSQL(sql); // 执行有更改的sql语句 }
@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DELETE FROM Topico"); db.execSQL("DELETE FROM Categoria"); }
@Override public void onCreate(SQLiteDatabase db) { db.execSQL(ScriptSQL.getCreateCategoria()); db.execSQL(ScriptSQL.getCreateTopico()); }