Reputation: 4614
After reading some articles & threads on stackoverflow. I found out that even files stored with Context.MODE_PRIVATE
can be read after rooting the device.
Then what are the options I have to store a file privately, which are only readable to my app.
Is encryption is only option I have ? I will keep file encrypted & only my app knows how to decrypt.
Does android platform provides any other mechanism for this purpose ?
Upvotes: 2
Views: 1173
Reputation: 261
Short answer: You cannot, although I see some suggestions for making it slightly more annoying for people to find your secret among the current answers.
Longer answer: You cannot 100% guarantee the security of any data, but this is particularly true if it's on a physical device in someone else's hands.
It's also true that APK code itself isn't all that secure from reverse engineering(link to online apk decompiler).
That being said, you have a much better chance of securing data on a server which can only be accessed by authenticated users.
This is probably many levels of overkill, but Payment Cards Industry (PCI) compliance standards for data handling (random link with an overview) might be a good place to start from, and then you can decide for yourself how much security you actually want to implement. These are the data security standards required for payment processors who store payment card numbers(BINs).
There are also a lot of smaller payment processors who outsource the PCI-compliant part of their data handling to companies who already have the infrastructure in place, rather than invest in building to the standard themselves, due to the high requirements.
I know about all this PCI stuff from engineering experience in the FinTech industry. :)
Upvotes: 1
Reputation: 3979
Apart from the mentioned solutions (encryption) , another solution is Cloud Storage from Firebase (if you do NOT save files locally and use Firestore cache instead):
https://firebase.google.com/products/storage
If your data can be saved in db (like shared preferences data) its even better to use Cloud Firestore:
https://firebase.google.com/products/firestore
Upvotes: 0
Reputation: 481
There are some libs that provide Secure Share Pref like Hawk that enough to serve your purpose.
Upvotes: 2
Reputation: 764
Indeed, encrypting your files seems like a good defense against unbidden access to your data.
Android offers you a range of tools to safely encrypt and decrypt your data:
Android offers methods to generate new key pairs and secret keys.
Upvotes: 2