写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);
本文介绍了如何在Android中利用SharedPreferences以Context.MODE_WORLD_READABLE模式进行数据存储,并演示了跨应用访问这些数据的方法。
472

被折叠的 条评论
为什么被折叠?



