I have created a delete function and would like for the serial number (srno) of each row after the deleted one to be decremented by 1 so that continuity without gaps is maintained. Is there any way of doing this?
public void deleteContact(Contact contact) {
SQLiteDatabase db = this.getWritableDatabase();
int next = contact.getSrno() + 1;
db.delete(Util.TABLE_NAME, Util.KEY_SRNO + "=?", new String[]{String.valueOf(contact.getSrno())});
//updateList();
db.close();
}
I can use the loop:
for(Contact contact : allContacts){}
But this includes unwanted items. I just wanted to know if there is a method to retrieve the key value (srno) of the last item in the list.