Search code examples
androidsharedpreferencesroot

Android: Modify SharedPreferences of another app


I'm trying to write application that must read, modify and save some settings in Shared preferences of another application (data/data/package_name/shared_prefs/file.xml).

This application isn't mine, and I have rooted device for testing.

What android permissions i should add to manifest and how can I access this file and modify it? I know that SharedPreferences are unique to each App/APK, but I need to modify it in root mode.

I have working code to modify xml file on sdcard, but when I change path to "data/data/package_name/shared_prefs/file.xml" it gives me an exception and message

android open failed eacces (permission denied)

Is there a way I can achieve that?


Solution

  • Take a look at this answer:

    https://stackoverflow.com/a/13139280/361230

    When you use su, you will have the permission to modify whatever you want on the filesystem.

    However, I agree with Chris on the fact it's not really nice to do what you want to.