Poldenais
Lurker
HI all, My Android app {app2} needs to read a value from an XML file stored in shared_prefs under another app{app1} [API 24].
In my app I put in the following Code to try and read the shared preferences file that is stored under app1 but its not working:
String key = "";
try {
con = createPackageContext("com.app1", Context.CONTEXT_IGNORE_SECURITY);
SharedPreferences prefs = con.getSharedPreferences("app1_conf", MODE_PRIVATE);
key = prefs.getString("ITEM1", "Couldn't Find");
Log.i("mainActivity", "My item is " + key);
} catch(PackageManager.NameNotFoundException e){
Log.e("Not Data Shared", e.toString());
}
In my app I put in the following Code to try and read the shared preferences file that is stored under app1 but its not working:
String key = "";
try {
con = createPackageContext("com.app1", Context.CONTEXT_IGNORE_SECURITY);
SharedPreferences prefs = con.getSharedPreferences("app1_conf", MODE_PRIVATE);
key = prefs.getString("ITEM1", "Couldn't Find");
Log.i("mainActivity", "My item is " + key);
} catch(PackageManager.NameNotFoundException e){
Log.e("Not Data Shared", e.toString());
}