You need to specify the application context. For instance:
Context otherAppsContext = null; try { otherAppsContext = createPackageContext("<YOUR_PACKAGE_NAME>", Context.MODE_WORLD_READABLE); } catch (NameNotFoundException e) { } SharedPreferences prefs = otherAppsContext.getSharedPreferences("PREFS_FILE", Context.MODE_WORLD_READABLE); String result = prefs.getString("PREFERENCE_TAG_NAME", "DEFAULT_VALUE");
This way you can read the contents of the general preference "PREFERENCE_TAG_NAME", which is saved in the file
/data/data/YOUR_PACKAGE_NAME/shared_prefs/<PREFS_FILE>.xml
You can do this in different applications that will work, but for this, "YOUR_PACKAGE_NAME" should be the same.
If you want to change the value in any application, you will need to change the getSharedPreferences mode from:
Context.MODE_WORLD_READABLE
in
Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE"
source share