Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8781401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:17:28+00:00 2026-06-13T20:17:28+00:00

I have my code: final EditText input2 = new EditText(mActivity); AlertDialog.Builder builder = new

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:17:29+00:00Added an answer on June 13, 2026 at 8:17 pm

    Use

    editor.putString("zipcode", input2.getText().toString());
    

    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:

    buider.setPositiveButton("OK", new DialogInterface.OnClickListener(){
        public void onClick(DialogInterface dialog, int id){
            SharedPreferences.Editor editor = prefs.edit();
            editor.putString("zipcode", input2.getText().toString());
            editor.commit();
            dialog.cancel();
        }
    });
    

    That way when the user is done typing and they hit the ok button, then, it will get the text the user entered

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following Java code: final Future future = exeService.submit( new Runnable() {
I currently have code that does the following: private final static ExecutorService pool =
I have the following code: private static final Set<String> allowedParameters; static { Set<String> tmpSet
I have a code to concatenate strings. However, for some reason, the final string
I have the following code: public void post(String message) { final String mess =
my question is that I have made multimap.Here is the partial code. if(binary_search(final.begin() ,
I have an AlertDialog.Builder displaying on an application. When I rotate the screen, I
I have an alertdialog with an editext. For this Edittext I make keyboard appear
So i have a menu item that shows AlertDialog with a EditText in it,
i have 1 edittext with number input only.the problem is,suppose user types 1234 no

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.