Storing/Retrieving Data with Shared Preferences
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.
Re: Storing/Retrieving Data with Shared Preferences
Probably should have been posted to the Android development forum but oh well.
If you just use getSharedPreferences() on a component you are creating an private shared preference only available to that activity. Use a PreferenceManager to get the default shared preference file instead.
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
// Add a key/value pair
SharedPreferences.Editor editor = prefs.edit();
boolean myValue = true;
// Retrieve a value