0

Is possible to hide or block access to the shared preferences file?

I'm using this file to store some information about mi apk and I would like to know if is possible not allowed to read or modify the file (including root devices).

Thank You very much in advance

carlosdiazp
  • 195
  • 1
  • 2
  • 17

2 Answers2

1

Sadly there would be no way to do that on a device, if a device has root it will have sufficient privileges to read your Shared Preferences as well as your SQLite databases and even Account Manager if it wants to.

You can look into linux file permissions if you want to learn more but any device that has root will be able to access your shared preferences.

If there is sensitive data on in your Shared Preferences just warn the user that if there device is rooted they are at risk. Traditionally for example on Nexus devices if you want to root the device it will wipe the entire thing but on specific devices there are exploits that won't require a wipe so you might be at risk.

Hope that helps.

Brosa
  • 1,169
  • 9
  • 19
1

You can store the data in encrypted form in SharedPrefernce. It will be simple approach. also by using proguard tool you can disable the reverse engineering of apk file.

chaitanya
  • 1,726
  • 2
  • 17
  • 13
  • hi. thanks for your answer. do you know if proguard tool also encrypt shared preferences variables? – carlosdiazp Jun 07 '13 at 10:59
  • 1
    It will not encrypt the shared pref variable. Proguard tool will not encrypt the String variables. So for that you have to make strings in ecrypted form & then you can add it to shared preferece i.e both key & value of shared pref should be encrypted. – chaitanya Jun 07 '13 at 11:07