Android: Modify SharedPreferences of another app

To actually answer your question, if you have root, you can do it with reflection. I have done it on android 4.1, on other platforms it may work differently. The good thing is that shared preferences is not accessible only by system services, so you can access "hidden" methods via reflection. Put this in a try-catch:

Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "chmod 777 /data/data/package_name/shared_prefs/package_name_preferences.xml" });
proc.waitFor();
proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "chmod 777 /data/data/package_name/shared_prefs" });
proc.waitFor();
proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "chmod 777 /data/data/package_name" });
proc.waitFor();

File preffile = new File("/data/data/package_name/shared_prefs/package_name_preferences.xml");

Class prefimplclass = Class.forName("android.app.SharedPreferencesImpl");

Constructor prefimplconstructor = prefimplclass.getDeclaredConstructor(File.class,int.class);
prefimplconstructor.setAccessible(true);

Object prefimpl = prefimplconstructor.newInstance(preffile,Context.MODE_WORLD_READABLE | Context.MODE_WORLD_WRITEABLE);


Editor editor = (Editor) prefimplclass.getMethod("edit").invoke(prefimpl);
//put your settings here
editor.commit();

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.