Search code examples
androidandroid-sqlite

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:

  1. where I can extract it that no one can access it even though they have a rooted device ?
  2. after extracting my database from zipfile ,I want to copy it to my application database . is there anyway users can access the database ?

Solution

  • 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.