How can I protect sqlite db in android from being stolen

Viewed 6634

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.

4 Answers

You cannot complete protect your SQLite db, for me, I prefer:

1- corrupt the db file (convert it to byte array and change some values)

2- copy it in asset folder

3- in first run fix corrupted file from asset and copy it in database folder.

I change first 200 byte values like this:

        int index = 0;
        for(int i=0;i<100;i++)
        {
            byte tmp = b[index];
            b[index] = b[index + 1];
            b[index + 1] = tmp;
            index += 2;
        }

As I just replace values of first 200 byte, the same code is used for fixing first 200 byte values.

Related