我想将我的数据库版本升级到 4。我在清单文件中更改了版本代码,我的数据库 openhelper 是
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
DTLog.w("Old Version" + oldVersion, "new Version" + newVersion);
DTLog.w("UPDATING DB", "Updating database");
if (oldVersion == 1 && newVersion == 2) {
db.execSQL("ALTER TABLE moduleRecord ADD COLUMN subtitle1 TEXT");
db.execSQL("ALTER TABLE moduleRecord ADD COLUMN subtitle2 TEXT");
db.delete("moduleRecord", null, null);
}
else if ((oldVersion == 2&&newVersion == 3)) {
db.execSQL("CREATE TABLE "
+ "moduleDesc"
+ "(deleteable INTEGER,createable INTEGER,updateable INTEGER,name TEXT,label TEXT,labelfields TEXT,fields TEXT);");
} else {
db.execSQL("DROP TABLE IF EXISTS " + "moduleRecord");
db.execSQL("DROP TABLE IF EXISTS " + "ModuleName");
db.execSQL("DROP TABLE IF EXISTS " + "EventStatus");
db.execSQL("DROP TABLE IF EXISTS " + "moduleDesc");
onCreate(db);
}
}
我得到的错误是
07-31 12:01:15.267: W/System.err(632):
android.database.sqlite.SQLiteException: no such table: moduleDesc: ,
while compiling: insert into moduleDesc(deleteable,createable,updateable,name,label,labelfields,fields)
values(?,?,?,?,?,?,?)
07-31 12:01:15.267: W/System.err(632):
at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
07-31 12:01:15.267: W/System.err(632):
at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)
07-31 12:01:15.267: W/System.err(632):
at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)
07-31 12:01:15.267: W/System.err(632):
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
谁能告诉我如何升级数据库