Marquis
Marquis

Reputation: 195

Reset to Default Preferences not updating EditTextPreferences

I am trying to implement a RESET to Default option, part of my settings. What it does is it reverts back to the default value. My issues is when I reset everything how can I also update the EditTextPreference value with the newValue? It updates only after exiting the activity and returning back to it.The preference is correctly updated but not the actual content of the EditTextP. Thank you for your time reading this!

@Override
                public void onClick(DialogInterface dialog, int which) {

                    SharedPreferences preferences = 
                            PreferenceManager.getDefaultSharedPreferences(PreferencesActivity.this); 
                    SharedPreferences.Editor editor = preferences.edit(); 

                    editor.clear();                         
                    editor.commit();

                    PreferenceManager.setDefaultValues(PreferencesActivity.this, R.xml.preferences, true);                      
                    editor.commit();                                                    

                    CheckBoxPreference enableEdit = (CheckBoxPreference)findPreference("IsChecked");    
                    enableEdit.setChecked(false);


                } }); 

Upvotes: 0

Views: 399

Answers (0)

Related Questions