Issue
i'm using SQLite to store data and if i delete the last row, ID is 4 and after that add a new row and the ID is 5 and it should be 4. And when trying to view the data it crashes since it can't find data from ID 5.
In database inspector left of the ID column is a row number. is this accessible since that would solve the problem or is it just a row number indicator in Android studio.
Thank you and have a nice day!
Solution
Got it working by adding these:
String strSQL1 = "UPDATE people_table SET id = (id +1) WHERE id < 1";
String strSQL = "UPDATE people_table SET id = (id -1) WHERE id > 1";
db.execSQL(strSQL);
db.execSQL(strSQL1);
The id
goes right one even if I delete something between first and last one.
And you need to remove autoincrement
from id
for this to work.
Answered By - Jon
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.