How to protect data in SQLite database?

Android: how to protect data in a SQLite database?

  • I'm currently developing an Android game which saves data into a SQLite database. This is not really "sensitive" data, but I don't want users to be able to modify it (for obvious reasons of game balance, as it would be cheating). And it's quite easy to access and modify a SQLite db when your phone is rooted (there are plenty of applications for that in the market). So should I even worry about that, or consider users with a rooted phone can do whatever they want including cheating and that's their choice? Or could I somehow encrypt the data I don't want them to modify, or add a MD5 checksum or something similar? Another approach would be to abandon SQLite altogether and use some kind of binary files with game data. Please let me know if some of you already encountered similar issues, and what are the approaches you followed, as well as the "good practices" in the Android gaming development community. Thanks.

  • Answer:

    Root access for everybody and security are mutually exclusive. Any application or user with root permissions can read and modify each and every file on your system, as well as all of the main memory. That doesn't leave many places to store a potential encryption key for the database. You could hide parts of the key in the executables, configuration files etc, but everything you could come up with would be nothing more than obfuscation and security by obscurity. If a user opts to grant root access to everybody, that's their decision, and it's not your job as an app developer to prevent any harm that might be caused. Update: http://stackoverflow.com/questions/4671859/storing-api-keys-in-android-is-obfustication-enough is a pretty similar issue - it's about protecting API keys, but it's the same situation with regards to your options.

Guillaume at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

sqlcipher for Android might help here. https://guardianproject.info/code/sqlcipher/

SK9

You may find your happiness on Preferences Files [Look http://developer.android.com/guide/topics/data/data-storage.html

Blood-HaZaRd

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.