-1

I wonder know if it is possible modify a SharedPreferences' xml file from external. If in my game I use SharedPreferences for save the score, is possible that the user, searching the xml file in the app directory, can modify the score with a simple text editor, so then the app read the wrong value? Thanks in advance :)

GreyBeardedGeek
  • 29,460
  • 2
  • 47
  • 67
LolloAAA
  • 112
  • 10
  • Well did you try it yourself? Please try and report here. – greenapps Apr 14 '17 at 11:40
  • 2
    If the device is rooted then yes it is possible to edit the prefs file, it is only xml key/value pairs, the same can be said for editing sqlite databases – Mark Apr 14 '17 at 11:42
  • 2
    If your concerned about cheating then you can use an algorithm to change the values, so they need to be coded/decoded - a simple level of abstraction would be to convert your prefs to Base64 strings .. it offers a bit more abstraction with minimal extra effort, however can still be deciphered. – Mark Apr 14 '17 at 11:53

2 Answers2

0

Bro don't worry. These all files saves on users google drive associated with there Google Play Account privately. No one can access it. Even if the the user uninstalls the App from the devices, It will be there always. When users re-install the app, It will fetch its data.

Ashish Gupta
  • 737
  • 11
  • 18
  • I think its more a case of stopping users cheating... the file can be easily changed on rooted devices which has elevated privileges. – Mark Apr 14 '17 at 11:50
0

Yes, BUT. Only if device is rooted, because preferences are stored in:

/data/data/YOUR_PACKAGE_NAME/shared_prefs/YOUR_PREFS_NAME.xml

And only root users can access /data folder. Btw, you can secure you preferences by encrypting key/value pair. Please refer to first answer for this question.

Community
  • 1
  • 1
Eugene Laminskiy
  • 594
  • 2
  • 11