Search code examples
androiddatabasesqlitesqlcipher-android

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


Solution

  • after deleting values use

    db.execSQL("VACUUM");
    

    the reason behind this is that when you delete values from table then values is deleted but their references are still there