I have two activities A and B. Activity A has a form and by clicking on submit button it saves the form data into shared preference. Activity B has to retrieve data from the shared preferences saved by activity A. I went through so many forums and got suggestion to uses getSharedPreference(Filename,Mode)
instead of getPreference(Mode)
. But still it does not work. Is there any other method to do this job instead of creating a class in activity A specially to extract shared preference values for public use.
Please suggest a perfect solution for this. I even used the mode as WORLD_READABLE.
I think the problem is that the editor is not actually committing changes due to how you are opening your SharedPreferences
.
SharedPreferences.Editor editor = getSharedPreferences("udata",MODE_WORLD_READABLE).edit();
Change MODE_WORLD_READABLE
to Context.MODE_PRIVATE
and see if that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With