/**
* Removes a {@link Preference} from this group.
*
* @param preference The preference to remove.
* @return Whether the preference was found and removed.
*/publicbooleanremovePreference(Preferencepreference){finalbooleanreturnValue=removePreferenceInt(preference);notifyHierarchyChanged();returnreturnValue;}privatebooleanremovePreferenceInt(Preferencepreference){synchronized(this){preference.onPrepareForRemoval();returnmPreferenceList.remove(preference);}}
/**
* Finds a {@link Preference} based on its key. If two {@link Preference}
* share the same key (not recommended), the first to appear will be
* returned (to retrieve the other preference with the same key, call this
* method on the first preference). If this preference has the key, it will
* not be returned.
* <p>
* This will recursively search for the preference into children that are
* also {@link PreferenceGroup PreferenceGroups}.
*
* @param key The key of the preference to retrieve.
* @return The {@link Preference} with the key, or null.
*/publicPreferencefindPreference(CharSequencekey){if(TextUtils.equals(getKey(),key)){returnthis;}finalintpreferenceCount=getPreferenceCount();for(inti=0;i<preferenceCount;i++){finalPreferencepreference=getPreference(i);finalStringcurKey=preference.getKey();if(curKey!=null&&curKey.equals(key)){returnpreference;}if(preferenceinstanceofPreferenceGroup){finalPreferencereturnedPreference=((PreferenceGroup)preference).findPreference(key);if(returnedPreference!=null){returnreturnedPreference;}}}returnnull;}