简体   繁体   English

在android中更新和压缩sqlite数据库

[英]updating and compacting sqlite database in android

I am a bit new to android and I am working on a project which used to have 40 MBs of sqlite database. 我对android有点新,我正在研究一个曾经拥有40 MB sqlite数据库的项目。 Now I wanna put blob data of sqlite in raw folder, so my database is now less than 1 MB. 现在我想把sqlite的blob数据放在raw文件夹中,所以我的数据库现在不到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). 问题是在数据库路径(数据/数据/包名/数据库)中,db文件大小仍然与过去相同(我的手机已植根,所以我可以在每次调试后检查它)。 In DB browser we can use compact database in order to reduce the db size after dropping some tables. 在DB浏览器中,我们可以使用压缩数据库,以便在删除一些表后减小db大小。 now what can I do ? 现在我该怎么办? any help would be appreciated. 任何帮助,将不胜感激。 tnx in advance. tnx提前。

The VACUUM command may be what you want. VACUUM命令可能是您想要的。

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 SQLite理解的SQL - VACUUM

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM