John Joe John Joe - 8 days ago 7
Android Question

SQLite id auto-increment

I have created a SQLite table by using query below

db.execSQL("create table " + TABLE__WORK + " ( " + ID1 + " INTEGER PRIMARY KEY ,Name TEXT, Title TEXT, Time TEXT, Date TEXT)");


The ID now can be auto-incremented. But after I perform delete query, delete the first row data and add again, the ID will start from
1
instead of
2
. Is it possible to make the id become
2
?

Answer

SQLite AUTOINCREMENT is a keyword used for auto incrementing a value of a field in the table.You do not need ID1.

See reference here

Please use this:

db.execSQL("create table " + TABLE__WORK + " (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,Name TEXT, Title TEXT, Time TEXT, Date TEXT)");
Comments