Do you know any ways to protect a database in Android?
I would like to implement the following, but don’t know whether it is possible:
- Limit access to the database to only the application owner (which created and serves it).
- Restrict or deny access to the database from all other applications during the usage session of DB owner application.
- Are there any ways to password protect your database?
Tests with sqlite3 showed that you can change the database while another application uses it. So, I assume that possibly some external application can corrupt your data or use it, which is bad.
Also, how do you propose to process a database exception that could occur during such simultaneous database usage:
- show to user message and close
- show to user message and continue working
- just close?
After all this happens, how do you propose to launch application next time?
Thanks
The android system automatically implements and enforces option (1) from your list. Every application on the phone/system has its own user ID, and no application can access the database files of any other application.
If you do want to share your data (with access controls), you can create a content provider, which can then be used by other applications: http://developer.android.com/intl/de/reference/android/content/ContentProvider.html
There are a couple of exceptions to the rules above:
Basically, you don’t need to worry about it. Android will normally prevent these issues for you.