简体   繁体   English

无法将android:process:xxx的共享首选项访问我的活动

[英]Unable to acces the shared preferences from android:process:xxx to my Activity

In my application, I created android:process:xxx. 在我的应用程序中,我创建了android:process:xxx。 I am trying to put a String value in preference from the process xxx components with the key of "name". 我正在尝试使用键“ name”从进程xxx组件中优先选择一个String值。 After this i am trying to get the value with same key from Activity. 在此之后,我试图从Activity获得具有相同键的值。 Activity is not belongs to process xxx. 活动不属于进程xxx。

I created my shared preference like below. 我创建了如下的共享首选项。

mPref = getSharedPreferences(PREF_FILE_NAME, MODE_MULTI_PROCESS);
mEditor = mPref.edit();

If you have two or more processes on your app, instead of shared preferences, create one table in your database. 如果您的应用上有两个或多个进程,而不是共享首选项,请在数据库中创建一个表。 Save the values in that table. 将值保存在该表中。

public SessionManager(Context context){
    this._context = context;
    //make mode as private
    pref = _context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
    editor = pref.edit();
}

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

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