I have an application with 7 separate views. In each of those views there is an option to answer a 'yes' or 'no.' We are trying to save these 'yes' or 'no' values using shared preferences. Then, we want to have a new view/layout and be able to call those values from shared preferences. How do I go about doing that? My group and I have tried several different ways but cannot seem to get it to work. I know I don't have any code posted but it's because my code is just in bits and pieces. Thanks.
2 Answers
In your case I would not use getSharedPreferences() because it creates separate prefs files. Instead, you should use the main preferences file (call getPreferences() from the main Activity). This will be easier for you to manage than using shared preferences files.
I would write some code to show you how to do this, but the Android training page on this is about as clear as can be. Can you look it over and see if it answers your question? If not, post back here for clarification and I'll do what I can to help.
Here's the link to the page: https://developer.android.com/training/basics/data-storage/shared-preferences.html

- 1,791
- 12
- 17
Simple Do following Steps :
1)call getDefaultSharedPreferences() to create shared preferences
2) for each view just put values
3)in final view just create preference using getDefaultSharedPreferences() and then retrieve all the values
Hope this will help you

- 886
- 1
- 10
- 20