Code example for CheckBoxPreference

Methods: setDependencysetKey, setChecked

0
	 */ 
	@SuppressWarnings("deprecation") 
	protected final CheckBoxPreference initBooleanPreference(String baseName, boolean defValue, String dependency) {
		// Update the loaded Preference with the actual preference key to load/store with 
		CheckBoxPreference pref = (CheckBoxPreference) findPreference(baseName);
		pref.setKey(baseName + "_" + key);
		pref.setDependency(dependency == null? null: dependency + "_" + key);
		// Update the Preference by loading the current stored value into the Checkbox, if it exists 
		pref.setChecked(sharedPrefs.getBoolean(baseName + "_" + key, defValue));
		return pref;
	} 
 
	/** 
	 * Updates a preference that allows picking an item from a list. No default value will be shown. 
	 * @param baseName The base name of the stored preference, e.g. item_name, which will then actually be stored under 
	 *            item_name_[key] 
	 * @return The concrete {@link ListPreference} that is bound to this preference 
	 */ 
	protected final ListPreference initListPreference(String baseName) {
		return initListPreference(baseName, null);
	}