Encrypt SQLite database without increasing app size?

android, database, encryption, sqlcipher

Solution

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:

- armeabi

- armeabi-v7a

- x86

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.

Problem

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.

Original source