Is there any way to encrypt the database of my android app with less increase in app size? I have tried SQLcipher, but it is increasing the size of my app by 10MB which is huge.
SQLite doesn't support encrypting database files by default. Instead, you need to use a modified version of SQLite like SEE, SQLCipher, SQLiteCrypt, or wxSQLite3.
SQLCipher is an extension to SQLite, but it does not function as a loadable plugin for many reasons. Instead, SQLCipher modifies SQLite itself, and is maintained as a separate version of the source tree. SQLCipher releases are baselined against a specific source version of SQLite.
You can password protect a SQLite3 DB. Before doing any operations, set the password as follows. conn = new SQLiteConnection("Data Source=MyDatabase. sqlite;Version=3;Password=password;"); conn.
SQLite is not itself encrypted. If you store text in a SQLite database, you should assume anyone with access to the device has access to the text.
It depends on your actual needs but a simple way would be to encrypt/decrypt the data itself before you write to / read from the database. This would have minimal impact on the apk size but there's more effort needed on your side.
If high security is required, just accept the 10MB and get on with life :-)
The increase of 10MB in your APK when using SqlCipher can be avoided by shipping a separate APK for each Android architecture you want to target.
For performance and cross platform support reasons SqlCipher is implemented in C code and built as a native Android .so library using the Android NDK. A different library is built for each Android architecture it supports, which in the case of SqlCipher are:
To minimize the file size increase caused by SqlCipher you can build a seperate APK that only includes the architecture that matches your users device. Take a look at the Android developers site on how to publish multiple APK's targeting different device configurations.
During my testing following this technique reduced my APK from 10MB to 4MB.
For further information this article details how to implement SqlCipher on Android and explains the file size increase.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With