寫SharedPreferences的時候設置屬性爲Context.MODE_WORLD_READABLE:
SharedPreferences sharedPreferences = getSharedPreferences(shareName, MODE_WORLD_READABLE);
訪問的時候:
Context otherContext = null;
try {
otherContext = createPackageContext("com.android.settings", Context.CONTEXT_IGNORE_SECURITY);
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
SharedPreferences sharedPreferences = otherContext.getSharedPreferences(shareName, MODE_WORLD_READABLE);