SQLCipher Database size keeps on growing even after deleting records from table

My Android application uses SQLCipher for a database encryption, as per my project requirement I need to store Bitmap String in my local database which needs to get removed from the database once uploaded to the server successfully. But here I met with a very weird issue with the SQLCipher i.e. even after deleting all the image strings from table my app’s database size doesn’t decrease rather it got increased. For instance my db’s initial size was 45 KB With 30 image strings in table size became 2.91 MB And, after deleting 30 images from table size got increased to 3.04 MB

But, when I did the same case with normal SQLite database i.e. without SQLCipher encryption, I got the expected results i.e. db size 2.91 got reduced to 50 KB after deleting the images from the table.

Please assist…

Hello @111

You may want to look into performing a vacuum of the database file. Unless you have auto_vacuum enabled, deleting data from the database will leave empty space as free database pages, maintaining a similar size on disk. If that resolves your issue, you might also consider using auto_vacuum feature. Please let us know if this resolves the issue for you.

@111 Did doing a vacuum on the database work? :slight_smile:

Hi guys,
is there somewhere manual how to apply/perform vacuum? We ran into similar issue when we are deleting images from database, but the database size doesn’t decrease. The problem is caused by the application database having grown to a size the app can no longer handle effectively (up to 8GB).

We are using in our project:

  1. net.zetetic.sqlcipherPlugin version 4.1.3
  2. for electron build: @journeyapps/sqlcipher 4.1.0

Thanks for help

Hi @marek8623

Would you mind reaching out to us directly at support@zetetic.net to discuss this further, it may be easier to sort out the details directly. Thanks!