android - accessing shared preferences from broadcast receiver -


this click event main activity. s3 edit text value want use in broadcast receiver when incoming call arrives.

 public void clicksave(view shilpa)  {    sharedpreferences sharedpreferences = getsharedpreferences("my_prefs", mode_private);    sharedpreferences.editor editor = sharedpreferences.edit();    editor.putstring("message", s3);    editor.commit(); } 

this using in broadcast receiver access value of s3 :

string pref = preferencemanager.getdefaultsharedpreferences(context).getstring("message", "does not exist"); 

but when try value here ,it comes "does not exist" instead of correct value. please tell me going wrong

might because using getdefaultsharedpreferences, try using

sharedpreferences prefs = getsharedpreferences("my_prefs", context.mode_private); string yourstring = prefs.getstring("message", "doesn't exist"); 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -