1. public void onCreate(SQLiteDatabase db)
create table
2.public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
已经存在的表升级操作
如加入列 alart 操作 事务批量操作
db.beginTransaction(); db.execSQL("ALTER TABLE favorites ADD COLUMN appWidgetId INTEGER NOT NULL DEFAULT -1;"); db.setTransactionSuccessful(); db.endTransaction();
或者 重建新表删除旧的表
3.public void onOpen(SQLiteDatabase db)
Called when the database has been opened
4.
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
throw new SQLiteException("Can‘t downgrade database from version " +
oldVersion + " to " + newVersion);
}
当新版本低于旧版本时候调用 抛出异常
5.public void onConfigure(SQLiteDatabase db) {}
db被配置时候调用 猜想是set name 版本好时候吧
时间: 2024-10-17 04:43:55