In short: In SQLite a column declared INTEGER PRIMARY KEY will autoincrement.
There is no autoincrement
keyword in SQLite, that is why you are getting an error.
You can find out more on SQLite FAQ.
EDIT: just writing integer primary key
it is enough. SQLite
will automatically increment your ids
.
EDIT2: Your onUpgrade()
method should look like this :
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (newVersion > oldVersion) {
Log.w("MyAppTag","Updating database from version " + oldVersion + " to "
+ newVersion + " .Existing data will be lost.");
db.execSQL("DROP TABLE IF EXISTS " + MY_TABLE);
db.execSQL("DROP TABLE IF EXISTS " + MY_TABLE2);
onCreate(db);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…