To answer your question, if you have a root, you can do it with reflection. I did it on android 4.1, on other platforms it may work differently. Itβs good that the general settings are not available only to system services, so you can access the βhiddenβ methods through 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);
source share