开发者

Deleting in database?

开发者 https://www.devze.com 2023-03-02 19:19 出处:网络
I 开发者_运维技巧have a question about the databases in Android. I had created in my app a database. If I delete a record from database, for example the last one, and after that I insert a new record

I 开发者_运维技巧have a question about the databases in Android. I had created in my app a database. If I delete a record from database, for example the last one, and after that I insert a new record in database, the new record is not saved in database in the row where I deleted the other record. That row is empty. It is saved in the next row. Why? Should I do something?


I'm assuming you are talking about an sqlite DB?

If your rowid is a field declared using AUTOINCREMENT, then (from the docs) the "ROWID chosen for the new row is at least one larger than the largest ROWID that has ever before existed in that same table".

You can read about the autoincrement algorithm here: http://www.sqlite.org/autoinc.html

Note that you do NOT have to use AUTOINCREMENT to have your primary key auto select a rowid.

0

精彩评论

暂无评论...
验证码 换一张
取 消