java - Reset AUTOINCREMENT in SQLite Database on Android? -


i'm using sqlite database in android auto increments _id field, when remove row it, _id has missing number instead of going 1-9 go 1,2,4,5,6,7,8,9, want go 1 - 8! there way this? sorry question being confusing, couldn't figure out how phrase it!

i'm using sqlite database in android auto increments _id field, when remove row it, _id has missing number instead of going 1-9 go 1,2,4,5,6,7,8,9, want go 1 - 8! there way this?

by 1 word no. describing normal behaviour. internal iterator of autoincrement hasn't memory, said when once generated id 3, won't generate id 3 again next number 4. if should have generated ids 1,2,3,4,5 , remove row id 5, new inserted row have automatic id 6 not 5.

in of dmss normal behaviour. sure, can achieve when won't use autoincrement explicitly added ids , when changes can provide update of rows programatically approach not recommended , "sick" because in case have milion rows in table, update milion rows , operation time-consume , devices not because have limited memory , battery capacity.

and @areks mentioned if using relational tables must update references , it's not worth in cases.

note: if populating adapter list of own defined objects can save reference row_id sqlite each object , when want delete row listview id row , pass parameter of delete method.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -