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

  • SEARCH
  • Home
  • 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 8449781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:48:13+00:00 2026-06-10T10:48:13+00:00

My problem is whenever I try to save what I input, specifically, checking appropriate

  • 0

My problem is whenever I try to save what I input, specifically, checking appropriate answer in a radiogroup, everything else was saved but not the selected radiobutton in a group. Please see my code if I’m missing something. It’s been days that this problem’s driving me mad.

private void saveData(){

     //get entered value and set to a variable
     String fname_input = fnametext.getText().toString();
     int checkedButton = gendertext.getCheckedRadioButtonId();


     //SAVE shared pref value
     SharedPreferences.Editor editor = settings.edit();
     editor.putString("fname", fname_input);
     editor.putInt("gender", checkedButton);
     editor.commit();

     //show button after saving
     Toast.makeText(Profile_Pref.this, 
                "You have successfully saved!",
                Toast.LENGTH_SHORT)
                .show();

 } // end of saveData method

Thanks for help!

for my loadSavedData method:
private void loadSavedData(){

    //RETRIEVE/load the saved shared pref value
     String fname = settings.getString("fname", null);

      fnametext.setText( fname );
      gendertext.setSelected(true);

 }   // end of loadSavedData method

I think there’s a logic error here 🙁

  • 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-10T10:48:14+00:00Added an answer on June 10, 2026 at 10:48 am

    I am assuming gendertext is a RadioGroup.

    The loadSavedData() needs to check the right radio button.

    private void loadSavedData(){
        //RETRIEVE/load the saved shared pref value
        String fname = settings.getString("fname", null);
    
        fnametext.setText( fname );
    
        gendertext.check(settings.getInt("gender", 0));
    }  
    

    On a separate note, you shouldn’t really store view IDs in preferences. They can change in future. Instead store gender values, like “M” and “F”.

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

Sidebar

Related Questions

I think I'm not the only one having this problem. Whenever I try to
Is there a compatibility problem with JQuery Mobile and mediaelements? Whenever I try to
I'm having a really difficult time debugging this problem. Whenever I try to establish
The problem I am facing with below code is that whenever I try to
My problem is that in WPF, whenever I try and change the colour of
hello i got a problem, whenever i try to write any simple thing inside
The problem I have is that whenever I try to drag and drop with
I have a minor problem. Whenever I try to build my project using the
Following problem: Whenever I try to sent a HTML-email through rails, it arrives at
I´m having a problem whenever i try to use WMI services on a virtual

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.