Code example for Preference

Methods: getContextgetKeysetOnPreferenceChangeListener

0
     * @see #sBindPreferenceSummaryToValueListener 
     */ 
    private static void bindPreferenceSummaryToValue(Preference preference) {
	// Set the listener to watch for value changes. 
	preference
	.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
 
	// Trigger the listener immediately with the preference's 
	// current value. 
	sBindPreferenceSummaryToValueListener.onPreferenceChange(
		preference,
		PreferenceManager.getDefaultSharedPreferences(
			preference.getContext()).getString(preference.getKey(),
				"")); 
    } 
 
    /** 
     * This fragment shows general preferences only. It is used when the 
     * activity is showing a two-pane settings UI. 
     */ 
    @TargetApi(Build.VERSION_CODES.HONEYCOMB)