我想在我的书籍表中添加新列,但显示错误:- 我做错了什么。
引起:android.database.sqlite.SQLiteException:表书已经存在
以上错误
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL( "CREATE TABLE books (id INTEGER PRIMARY KEY AUTOINCREMENT,title TEXT ,author TEXT,isbn TEXT,city TEXT );");
Log.v("onCreate-------","called onCreate");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
android.util.Log.w("books",
"Upgrading database, which will destroy all old data");
//db.execSQL("DROP TABLE IF EXISTS books");
db.execSQL("ALTER TABLE books ADD COLUMN city2 TEXT");
onCreate(db);
Log.v("onUpgrade-------","called onUpgrade with alter");
}