Java tutorial
//package com.java2s; //License from project: Open Source License import android.preference.Preference; import android.preference.PreferenceFragment; import android.preference.PreferenceGroup; public class Main { /** * Removes a {@link Preference} from the {@link PreferenceCategory} with the given key. */ public static void removePreference(PreferenceFragment prefFrag, int parentKey, int prefKey) { String parentName = prefFrag.getString(parentKey); String prefName = prefFrag.getString(prefKey); PreferenceGroup parent = (PreferenceGroup) prefFrag.findPreference(parentName); Preference child = prefFrag.findPreference(prefName); if (parent != null && child != null) { parent.removePreference(child); } } }