我创建一个Android应用程序,有最近通话记录。 我想限制该表为最大50行的大小(根据其插入日期)
I create an Android app that has "recents history". I would like to limit the size of this table to a maximum of 50 rows (according to their insert date).
我看到谈论限制删除的行数的多个线程,但我不知道这功能在Android的SQLite的,即使启用。
I saw several threads that talk about limiting the number of deleted rows, but I'm not sure if this feature is even enabled in Android's SQLite.
谁能帮助吗?
感谢
我觉得SQL不能管理的行数在表,所以你必须自己去管理它。您可以执行数据插入后查询,将降低数据 - 这样的事情应该工作
I think sql can't manage the number of rows in your table so you'll have to manage it by yourself. You can execute query after data insertion that will reduce the data - something like this should work
DELETE FROM table where _id NOT IN (SELECT _id from table ORDER BY insertion_date DESC LIMIT 50)
上一篇:是否有一个机器人的外壳,或者我可以用它来获取设备的IMEI / MEID ADB命令?可以用、它来、机器人、外壳
下一篇:在我的web应用程序,为什么不是我的machine.config中的HttpModule运行?我的、应用程序、不是、web