+ 1
How to reset sqlite database id
if I have 1,2,3,4,5 as my IDs for my sqlite database and I have deleted row 3. How can I reset the 🆔s for them to be 1,2,3,4?
3 ответов
+ 2
Sql doesn't allow query to remove id, even the id has been deleted.
The only way is to recreate the table with new data.
+ 1
Sorry, i dont get what you mean, please share code out.
0
OK thanks
But am having problem with my Recycleview when I delete an entry which ID is not the max row_id. When the Recycleview load from onCreate everything is fine but afterwards when I delete something, e.g #3 above and if I add another items, it will be added to the database with Max Id +1 alright, but the Recycleview arraylist will be cause an error saying indexOutOfBoundException, this is due to the deleted item in the database so if the max id in the database is 5 it will 3 in the arraylist which should have been 4. So that is the problem. I need help.