android getDefaultSharedPreferences doesn't get applied -


i'm new android development , i'm working on fixing bugs. app shouldn't load previous preference load instead of loading default values.

here have in main activity

    preferencemanager.setdefaultvalues(this, r.xml.preferences, false);     // register listener sharedpreferences changes     preferencemanager.getdefaultsharedpreferences(this).registeronsharedpreferencechangelistener(preferencechangelistener);          quizfragment quizfragment = (quizfragment) getfragmentmanager().findfragmentbyid(r.id.quizfragment);         quizfragment.updateguessrows(preferencemanager.getdefaultsharedpreferences(this));         quizfragment.updateregions(preferencemanager.getdefaultsharedpreferences(this));         quizfragment.updatenumberquestions(preferencemanager.getdefaultsharedpreferences(this)); 

and here full code https://github.com/jamin567/android

try way:

 final string eulakey = "mykey";     context mcontext = getapplicationcontext();     mprefs = mcontext.getsharedpreferences("myappprefs", context.mode_private);     sharedpreferences.editor editor = mprefs.edit();     editor.putboolean(eulakey, true);     editor.commit(); 

in case can specify own preferences file name (myappprefs) , can control access persmission it. other operating modes include: mode_world_readable, mode_world_writeable, mode_multi_process


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -