How to prevent hacker access my app's database on android?

android, security

Solution

One option is to encrypt the data stored in database. Normally it is stored in plaintext. SQLCipher, I believe works for Android too..

From Android/google official forums,

Users with rooted phones can get access to any files they want. Otherwise, databases in the conventional on-board flash location are secure.

If you want to prevent that (routed access) only option is to encrypt it. However long it takes.

EDIT:

What I am saying is, it is never completely secure. You can make it as much difficult for hackers. You can save the decryption key (only) in the server (if downloading entire data from server is time consuming) but then app needs net connection to work. You can save the key in a hidden file (filename starting with .), but rooted users with knowledge about linux type file system can find them. Or you can do as Teovald suggests it in the comment to this answer, by generating the key in run time using any hash algorithm from any constants (like IMEI number), but it also need some processing. The more you try to secure it, the more works you need to do to use it. So it is a 50-50 kind of situation, and decision should depends on one's requirement.

Problem

as you know, we can access to any folder on android device after rooting. My app has a database and some other binary files. I know that I can't prevent user see my files and database. But is there any way to prevent user copy it to other android devices for illegal use?

Original source