这篇文章将为大家详细讲解有关Android中跨进程时出现SharedPreferences异常如何解决,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
Android 跨进程SharedPreferences异常详解
Context c = null;
try {
c = context.createPackageContext(PREFERENCE_PACKAGE,
Context.CONTEXT_IGNORE_SECURITY);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
if (c != null) {
SharedPreferences infoSp = c.getSharedPreferences(PREFERENCE_NAME,
Context.MODE_MULTI_PROCESS);
int status = infoSp.getInt("break", 1);
Logcat.d("br" + status);
return 0 == status;
} else {
Logcat.w("brake_status error.... c==null ");
}
return false;
关于Android中跨进程时出现SharedPreferences异常如何解决就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。