简体   繁体   中英

Set default value of ListPreference via service

I have 1 service for notification and after i received notification i want to set preference to desire value. Is it possible? how?

and because it is a service so I can't use

ListPreference  lp = (ListPreference) findPreference ("key");

any idea? thanks in advance.

Can you use

SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
prefs.edit().putString("key", "val").commit();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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