try {
ctx =createPackageContext("com.example.sharetest01",
Context.CONTEXT_IGNORE_SECURITY);
} catch (NameNotFoundException e) {
Log.e("tag", "没有这个包");
}
SharedPreferences sp = ctx.getSharedPreferences("test",
Context.MODE_WORLD_READABLE|Context.MODE_WORLD_WRITEABLE);
String value =sp.getString("test", "null");
转载于:https://blog.51cto.com/vincenttung/1221640