switchpreference - How to enable and disable action on switch preference in android

This is not working with switch preference please help .......to write another code..SwitchPreference uiTestModePref = (SwitchPreference) findPreference("switch");uiTestModePref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object o) { boolean check = (preference).isEnabled(); if (check) { android.provider.Settings.System.putInt(getContentResolver(), android.provider.Settings.System.HAPTIC_FEEDBACK_ENABLED, 1); ...Read more