Code example for PreferenceScreen

Methods: findPreference, removePreference

0
        super.onResume(); 
        refreshDefault(); 
        refreshCustomApplicationPrefs(); 
        getListView().setOnItemLongClickListener(this);
        getActivity().invalidateOptionsMenu(); 
    } 
 
    private void refreshDefault() { 
        ContentResolver resolver = getContentResolver();
        int color = Settings.System.getInt(resolver,
                NOTIFICATION_LIGHT_PULSE_DEFAULT_COLOR, mDefaultColor);
        int timeOn = Settings.System.getInt(resolver,
                NOTIFICATION_LIGHT_PULSE_DEFAULT_LED_ON, mDefaultLedOn);
        int timeOff = Settings.System.getInt(resolver,
                NOTIFICATION_LIGHT_PULSE_DEFAULT_LED_OFF, mDefaultLedOff);
 
        mDefaultPref.setAllValues(color, timeOn, timeOff);
 
        // Get Missed call and Voicemail values 
        if (mCallPref != null) {
            int callColor = Settings.System.getInt(resolver,
                    NOTIFICATION_LIGHT_PULSE_CALL_COLOR, mDefaultColor);
            int callTimeOn = Settings.System.getInt(resolver,
                    NOTIFICATION_LIGHT_PULSE_CALL_LED_ON, mDefaultLedOn);
            int callTimeOff = Settings.System.getInt(resolver,
                    NOTIFICATION_LIGHT_PULSE_CALL_LED_OFF, mDefaultLedOff);
 
            mCallPref.setAllValues(callColor, callTimeOn, callTimeOff);
        } 
 
        if (mVoicemailPref != null) {
            int vmailColor = Settings.System.getInt(resolver,
                    NOTIFICATION_LIGHT_PULSE_VMAIL_COLOR, mDefaultColor);
            int vmailTimeOn = Settings.System.getInt(resolver,
                    NOTIFICATION_LIGHT_PULSE_VMAIL_LED_ON, mDefaultLedOn);
            int vmailTimeOff = Settings.System.getInt(resolver,
                    NOTIFICATION_LIGHT_PULSE_VMAIL_LED_OFF, mDefaultLedOff);
 
            mVoicemailPref.setAllValues(vmailColor, vmailTimeOn, vmailTimeOff);
        } 
 
        mApplicationPrefList = (PreferenceGroup) findPreference("applications_list");
        mApplicationPrefList.setOrderingAsAdded(false);
    } 
 
    private void refreshCustomApplicationPrefs() { 
        Context context = getActivity();
 
        if (!parsePackageList()) { 
            return; 
        }