In my App, I want to show a Dialog, where the user has to fill in an email address.
When OK is pressed, this entered address should be set as a summary in my PreferenceActivity.
(I want to change the summary of a Preference from another (myDialog) Activity.)
Edit:
builder.setPositiveButton(R.string.okay), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if(Utilities.isValidEmail(userEmail.getText())) {
//don't know how to access preference and save text as summary
}
}
}
Solution:
When OK from Dialog was pressed:
PreferenceManager.getDefaultSharedPreferences(context).edit().putString("email", enteredMail).commit();
When the Settings onCreate
method is called:
String mail = sharedPreferences.getString("email", "no entered Mail");
Preference eMail = findPreference("preference_key");
eMail.setSummary(mail);