I have a subclass of DialogPreference called MyDialogPreference, it has two EditTexts for username and password, when I click in the DialogInterface.BUTTON_POSITIVEbutton, I set some preferences like this: 
//I get userId from SQLite before this
SharedPreferences settings = this.getContext()
                .getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putInt("userId", userId);
editor.commit();
I want that in my SettingsFragment that called the DialogPreference, whenever I close MyDialogPreference, I could be able to show the data changed as a summary of the Preference
Here's the layour of Preferences:
    <Preference
        android:key="update"
        android:title="Update other preference" >
    </Preference>
    <com.cmr.MyDialogPreference
        android:key="userPassScreen"
        android:title="Login User" >
    </com.cmr.MyDialogPreference>
I was trying to bind this DialogPreference to OnPreferenceChangeListener, but it didnt work.
Here's the code for that also:
DialogPreference userPassScreen = (DialogPreference) findPreference("userPassScreen");
userPassScreen
            .setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
                @Override
                public boolean onPreferenceChange(Preference preference,
                        Object newValue) {
                    SharedPreferences settings = context
                            .getSharedPreferences(PREFS_NAME, 0);
                    int userId = settings.getInt("userId", 0);
                    if (userId == 0) {
                        preference.setSummary("Please Login");
                        return false;
                    }
                    try {
                        preference.setSummary(String.valueOf(userId));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    return false;
                }
            });
Is there any way I can make this?
PS. Sorry for my bad english
 
    