I have a database with tables |ID|NAME|
, and I have a function which deletes a row in the table .
public void deleteWord (int id ){
SQLiteDatabase db = this.getWritableDatabase();
db.delete(TABLE_WORDS, KEY_ID + "="+id, null);
db.close();
}
this is how I create my table
String createSetTable =
"CREATE TABLE "+TABLE_SETS+"("
+KEY_SET_ID+ " INTEGER PRIMARY KEY, "
+KEY_SET_NAME+ " TEXT) ";
db.execSQL(createSetTable);
The problem is that this function deletes a row with the given ID , and that ID remains empty like an array .For example I have a table
|1|Mike|
|2|Jane|
|3|Dave|
|4|Kate|
after using 'deleteWord (2)' i get something like this and the whole algorithm of the program is messed .
|1|Mike|
|3|Dave|
|4|Kate|
So what can I do to update my ID every time I delete a row ? Is there a special query which does it automatically ??