'android-How to protect a file from copying or seeing by users
I'm working on an application that it took me about 2 whole month to collect data. how can I protect my database and files? because of a big size of database, I zipped it (with password) and put it in asset folder. I can unzip it.
2 questions:
- where I can extract it that no one can access it even though they have a rooted device ?
- after extracting my database from zipfile ,I want to copy it to my application database . is there anyway users can access the database ?
Solution 1:[1]
Depends on how smart an attacker you're expecting. If you're expecting the average user, don't worry about it- just put it in your data directory, they'd have to root the phone to see it. From a power user you can encrypt the files. From a determined hacker that won't work- he'll decompile the apk and find the key. You can pass the key from a website, but a good hacker will run it under a debugger and find the key in memory. The best way to secure most of the data would be not to have it in the app but only download what you need via webservice as you need it, but that will cost money and time.
Solution 2:[2]
As I know there is no way to hide your files from user sight. they can access your resources sometimes so easy. but you should encrypt your data.
You can use SQLCipher library to protect your data. see http://sqlcipher.net/
Although it has some overhead but you can distribute your data in a safe way. Hope it can help you
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Gabe Sechan |
Solution 2 | Mojtaba Mahamed |