Reputation: 930
I have a method like this:
private void insertData() {
ContentValues cv = new ContentValues();
cv.put(name, "aName");
cv.put(lastName , "aLastName");
Uri returnedUri = getContentResolver().insert(CONTENT_URI, cv);
Log.e("number of row : " , returnedUri.toString());
}
I have 4 rows in my database and in the log message it will return .../persons/31 or a greater number each time. I expect that new inserted person should have id 5. I think every time I add a new person id increase by one but after deleting a person id won't automatically decrease by one.
Upvotes: 1
Views: 46
Reputation: 1209
This is pretty typical of SQL databases, while I don't know exactly why, or how, but they have an incremental on add counter, which means every new insertion will be +1 whatever the last value of the counter is. As best i know there's no way around this short of resetting the database
Upvotes: 1
Reputation: 549
The id will never decrease after delete the person because id is the unique key for every person it means if you delete one person it can not give that person identity which is id in this case to another person.Got it?
Upvotes: 1