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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -