I have my code:
final EditText input2 = new EditText(mActivity);
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
builder.setTitle("User Info Request:");
builder.setMessage("Enter Zip Code:");
final EditText input2 = new EditText(mActivity);
builder.setView(input2);
SharedPreferences.Editor editor = prefs.edit();
editor.putString("zipcode","input2");
editor.commit();
}
How can i take that string/text the user entered and replace my shared preferences value ‘zipcode’ with the value Input2 ? The way i try now it sets the “zipcode” shared pref to “input2” but i need the result of user input to change the existing value in shared prefs… =/
I have made several attempts at this with no luck, and help would be great.
Droidster
Use
You received the error because, as it says, you can’t put an edit text into the putString method; it needs to be of type String.
Also, I don’t see where you have your buttons.
Try this:
That way when the user is done typing and they hit the ok button, then, it will get the text the user entered