* In order for the default values to be populated into the * {@link SharedPreferences} (from the preferences XML file), the client must * call * {@link PreferenceManager#setDefaultValues(android.content.Context, int, boolean)}. *
* This should be called early, typically when the application is first created.
* This ensures any of the application's activities, services, etc. will have
* the default values present, even if the user has not wandered into the
* application's settings. For ApiDemos, this is {@link ApiDemosApplication},
* and you can find the call to
* {@link PreferenceManager#setDefaultValues(android.content.Context, int, boolean)}
* in its {@link ApiDemosApplication#onCreate() onCreate}.
*/
public class DefaultValues extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.default_values);
}
}
//xml/default_values.xml