繁体   English   中英

问题检索共享首选项值

[英]Issue retrieving Shared preference values

我们从一个应用程序中保存以下内容:

final CheckBoxPreference mCheckPref = new CheckBoxPreference(sContext);
mCheckPref.setKey("alertnotification");

我们从第二个应用程序中检索它:

mContext = context.createPackageContext("com.android.abc",Context.CONTEXT_INCLUDE_CODE |     Context.CONTEXT_IGNORE_SECURITY);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
boolean alertnotification = prefs.getBoolean("alertnotification",true);

即使在第一次将默认值设置为true的情况下,我也总是将Alertnotification设置为false。 为什么会这样?

http://developer.android.com/reference/android/content/SharedPreferences.html

“注意:当前此类不支持跨多个进程的使用。稍后将添加。”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM