updating and compacting sqlite database in android

一笑奈何 提交于 2019-12-12 12:14:31

问题


I am a bit new to android and I am working on a project which used to have 40 MBs of sqlite database. Now I wanna put blob data of sqlite in raw folder, so my database is now less than 1 MB. The problem is that in the database path(data/data/package name/databases) the db file size is still the same as the past(my cellphone is rooted so I can check it after each debugging). In DB browser we can use compact database in order to reduce the db size after dropping some tables. now what can I do ? any help would be appreciated. tnx in advance.


回答1:


The VACUUM command may be what you want.

This will copy the data to a temporary database and then use this to overwrite the original.

You would use something along the lines of:-

    db.execSQL("VACUUM");

Note the warnings about compatibility in the following:-

SQL As Understood By SQLite - VACUUM



来源:https://stackoverflow.com/questions/46694737/updating-and-compacting-sqlite-database-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!