SettingProvider exmaple

1. define new shared variable and default value
frameworks/base/core/java/android/provider/Settings.java
public static final String AAA_ENABLED = "aaa_enabled";

frameworks/base/packages/SettingsProvider/res/values/defaults.xml  
<bool name="def_aaa_enabled">true</bool>

frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
loadBooleanSetting(stmt, Settings.Secure.AAA_ENABLED,
        R.bool.def_aaa_enabled);

important file       
frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java

2. read/write shared variable
import android.provider.Settings;
read:
boolean aaa = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.AAA_ENABLED, 1) ==1;
write:
Settings.Secure.putInt(context.getContentResolver(), Settings.Secure.AAA_ENABLED, enable ? 1 : 0);

3. read from sqlite3
 adb shell sqlite3 data/data/com.android.providers.settings/databases/settings.db "select * from secure" | grep aaa

你可能感兴趣的:(SettingProvider)