I am using Edittextpreference as one of the preference in settings section. I want to validate this edittextpreference when the user enters data to it and clicks ok; before saving it in sharedpreference.
I am trying to do something like this but this saves the preference first I suppose.
editTextPreference
.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference,
Object newValue) {
if (((newValue.toString().length() == 15) {
// save preference only if length is equal to 15
}
})
});
can someone guide me how to validate edittextpreference before it is saved in sharedpreference so that I can decide if I want to save it or not.