Reputation: 21335
It is often nice to have some default values in Shared Preferences to begin with. Is there a good way to initialize them from an xml file or property file? Looking for the best way to do this. Thanks.
Upvotes: 8
Views: 9919
Reputation: 10232
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Make sure default values are applied. In a real app, you would
// want this in a shared function that is used to retrieve the
// SharedPreferences wherever they are needed.
PreferenceManager.setDefaultValues(getActivity(),
R.xml.advanced_preferences, false);
}
Upvotes: 0