修复创建数据库没有创建分类表引起的崩溃

This commit is contained in:
sonichy 2023-02-25 11:10:11 +08:00
parent 47d2634531
commit 2b8a445081
2 changed files with 3 additions and 3 deletions

BIN
app.apk

Binary file not shown.

View File

@ -31,15 +31,15 @@ public class DBHelper extends SQLiteOpenHelper {
public void onCreate(SQLiteDatabase db) {
this.db = db;
db.execSQL("CREATE TABLE webfav (_id INTEGER PRIMARY KEY , website TEXT, title TEXT, category TEXT)");
db.execSQL("CREATE TABLE category (_id INTEGER PRIMARY KEY , category TEXT)");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
switch (newVersion) {
case 3:
String sql = "CREATE TABLE category (_id INTEGER PRIMARY KEY , category TEXT)";
db.execSQL(sql);
sql = "ALTER TABLE " + TableName + " ADD COLUMN category TEXT default ''";
db.execSQL("CREATE TABLE category (_id INTEGER PRIMARY KEY , category TEXT)");
String sql = "ALTER TABLE " + TableName + " ADD COLUMN category TEXT default ''";
db.execSQL(sql);
break;
}