简体   繁体   English

Android数据存储问题

[英]Android data storage issue

I have an app which stores data in a SQLite database, when the app is just installed it uses 8kb of data and when I start inserting data obviously the size increases. 我有一个应用程序,它将数据存储在SQLite数据库中,当应用程序刚安装时,它使用8kb的数据,当我开始插入数据时,显然大小增加。 The weird thing is when I start cleaning my database tables, I empty completely the database but I will never recover the first 8kb of data but much more, in some cases more than 100kb, where this data come from? 奇怪的是,当我开始清理我的数据库表时,我完全清空了数据库,但我永远不会恢复第一个8kb的数据,但更多,在某些情况下超过100kb,这些数据来自哪里?

A database is not like a filesystem, so when you delete data from a database, you do not recover the space you previously used. 数据库与文件系统不同,因此从数据库中删除数据时,不会恢复以前使用的空间。 The database driver will tend to prefer to keep the old allocated space. 数据库驱动程序倾向于保留旧的已分配空间。

You can compact your database, which will recover this space by manually executing the SQLite VACUUM command. 您可以压缩数据库,这将通过手动执行SQLite VACUUM命令来恢复此空间。

It may be possible to enable auto_vacuum mode, but this needs to be done before database creation. 可以启用auto_vacuum模式,但这需要在创建数据库之前完成。

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

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