在android中更新和压缩sqlite数据库 [英] updating and compacting sqlite database in android

查看:153
本文介绍了在android中更新和压缩sqlite数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对android有点陌生,我正在做一个项目,该项目以前有40 MB的sqlite数据库. 现在我想将sqlite的blob数据放在原始文件夹中,所以我的数据库现在不到1 MB. 问题是在数据库路径(数据/数据/程序包名称/数据库)中,db文件的大小仍然与过去相同(我的手机已经扎根,因此我可以在每次调试后检查它). 在数据库浏览器中,我们可以使用紧凑型数据库,以便在删除某些表后减小数据库大小.现在该怎么办? 任何帮助,将不胜感激. 提前tnx.

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.

推荐答案

VACUUM 命令可能就是您想要的.

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.

您将使用以下内容:-

    db.execSQL("VACUUM");

请注意以下有关兼容性的警告:-

Note the warnings about compatibility in the following:-

SQLite理解的SQL-VACUUM

这篇关于在android中更新和压缩sqlite数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆