I am developing an android application as my final school project and I came to a problem.
I've created a table in SQLite which stores the information from users like ID, Name, Phone, Email Address etc. but I'd like to insert the data in an ordered way to always insert users using sequential ordering. In my Add_new_user_activity I have an EditText field which I want to be dynamically auto set with the next available ID from the existing ID's in the table, but I don't know how to handle the gaps that could be generated if an user is deleted between two sequential IDS.
Let say that I have this sequential records on the table:
Users from 1 to 50 with it's corresponding ID's.
Then I delete the 27 and 29 user.
The next time I want to add a new user I want the EditText to know that there is a gap between the ID 26 and 28 and take the 27 for the new user ID and do the same if I add new users. In this case if I add 2 more new users their respective ID's would have to be 29 and 51.
Is there a way to solve it efficiently?
Thank you in advance!
Aucun commentaire:
Enregistrer un commentaire