• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.example.android.apis.app;
18 
19 import com.example.android.apis.ApiDemosApplication;
20 import com.example.android.apis.R;
21 
22 import android.app.Application;
23 import android.content.SharedPreferences;
24 import android.os.Bundle;
25 import android.preference.PreferenceActivity;
26 import android.preference.PreferenceManager;
27 
28 /**
29  * This activity is an example of a simple settings screen that has default
30  * values.
31  * <p>
32  * In order for the default values to be populated into the
33  * {@link SharedPreferences} (from the preferences XML file), the client must
34  * call
35  * {@link PreferenceManager#setDefaultValues(android.content.Context, int, boolean)}.
36  * <p>
37  * This should be called early, typically when the application is first created.
38  * This ensures any of the application's activities, services, etc. will have
39  * the default values present, even if the user has not wandered into the
40  * application's settings. For ApiDemos, this is {@link ApiDemosApplication},
41  * and you can find the call to
42  * {@link PreferenceManager#setDefaultValues(android.content.Context, int, boolean)}
43  * in its {@link ApiDemosApplication#onCreate() onCreate}.
44  */
45 public class DefaultValues extends PreferenceActivity {
46 
47     @Override
onCreate(Bundle savedInstanceState)48     protected void onCreate(Bundle savedInstanceState) {
49         super.onCreate(savedInstanceState);
50 
51         addPreferencesFromResource(R.xml.default_values);
52     }
53 
54 }
55