 <p>Try setting the <a href="http://developer.android.com/reference/android/preference/Preference.html#setOnPreferenceChangeListener%28android.preference.Preference.OnPreferenceChangeListener%29" rel="nofollow">setOnPreferenceChangeListener</a> for your editPreference in onCreate(), put your validation code inside this callback.</p> <p>Reading the docs, they say <a href="http://developer.android.com/reference/android/content/SharedPreferences.OnSharedPreferenceChangeListener.html" rel="nofollow">OnSharedPreferenceChangeListener</a> is called when the shared preference is changed(is already changed). In the other hand the setOnPreferenceChangeListener is triggered "when this Preference is changed by the user (but before the internal state has been updated)"</p>