Skip to content

How can I protect sqlite db in android from being stolen

I am making a app with 28MB size of sq-lite file which is initially in assets folder of android. When it installs in user it copy’s to system folder. As this db is most important for me. If anyone can get this file then he can steal my information.

As you unzip the APK file you will easily get the sq-lite file. Is there any way to protect it or hide it or encrypt it so a programmer or hacker can’t get the db easily by extracting APK file.

Answer

You cannot complete protect your SQLlite DB as someone can reverse engineer your code and read the content of your protection mechanism.

You can take an alternate paths:

1) Make the DB online, i.e. don’t put it with your app, have your product contact your DB and query it

2) Encrypt the data in the SQL Lite, and decrypt it on the fly inside your code – this will make it harder to just steal your SQL Lite, it is not prefect, but it is better than nothing