java - How to access a SharedPreferences field? -


i'm trying access sharedpreferences field declared in activity sax parser class.

i tried using getdefaultsharedpreferences(context), unable find context pass argument method sax parser doesn't extend activity.

how can access field ?

now, let's suppose managed this. have second problem here : sharedpreferences field declared in activity (a class extending preferenceactivity actually). in sharedpreferences field, can store boolean values 2 lists of checkboxes, standing 2 lists of multi choice preferences.

i need know value of these lists of preferences "true". how can ?

here code :- pref.java

public class pref extends preferenceactivity implements onsharedpreferencechangelistener { static sharedpreferences pref;  public void oncreate(bundle saveinstancestate) {     super.oncreate(saveinstancestate);      pref = getpreferencemanager().getsharedpreferences();     pref.registeronsharedpreferencechangelistener(this);      int c = pref.getint("numrun",0);     c++;     pref.edit().putint("numrun",c).commit();     addpreferencesfromresource(r.xml.prefs); } 

i think need first access pref, have 2 multi choices preferences lists. how values these lists?

try this...

sharedpreferences prefs;  prefs = preferencemanager.getdefaultsharedpreferences(this);  username = prefs.getstring("username","");  password = prefs.getstring("password",""); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -