简体   繁体   中英

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. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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