Reputation:
I'd like to use the backup agent for saving user preferences:
http://developer.android.com/guide/topics/data/backup.html
In the article, it's explained how to backup SharedPreferences:
http://developer.android.com/guide/topics/data/backup.html#SharedPreferences
However it's not explained how to backup when a PreferenceActivity (http://developer.android.com/reference/android/preference/PreferenceActivity.html) is used to save user preferences!
My application has a Setting Activity extending PreferenceActivity, which loads the settings from a preference.xml file (where a PreferenceScreen is configured). When the PreferenceActivity is displayed, the user can set the values of the preferences. How can I use the Data Backup API to save user data set with a PreferenceActivity?
Upvotes: 0
Views: 871
Reputation: 4034
SharedPreferences is a Class with access to the preferences that the PreferenceActivity generats. In other word the default preferences use the sharedPreferences class the same way you would if you did it manualy. The key it usus is of course the key you gave it in the preferences.xml
Therefore you can use SharedPreferences as detailed in the link you provided with the settings which the preference activity added for you.
Upvotes: 3