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 9132899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:23:36+00:00 2026-06-17T08:23:36+00:00

So basically what I want to do is to save strings for selected choices

  • 0

So basically what I want to do is to save strings for selected choices and some entered text in edit texts (to remember age that kind of things that don’t change easily/fast) so when the user restarts the application he doesn’t need to enter all that information again.

But I’ve been looking all over the internet about saving strings in shared preferences or internal memory and I can’t understand lots of things and I can’t get it to work.

So my question is can someone please provide me sample code for 1 radio group or 1 editText (it’s enough) how to remember the selected choice in string or the entered value so the next time when the app is started that string is called the choice/text is set automatically.

  • 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-17T08:23:37+00:00Added an answer on June 17, 2026 at 8:23 am

    This is from a previous answer of mine, but it will work for you.

    private void savePreferences(){
        // We need an Editor object to make preference changes.
        SharedPreferences.Editor editor = getPreferences(MODE_PRIVATE).edit();
        editor.putString("editText1", editText1.getText().toString());
        editor.putString("editText2", editText2.getText().toString());
    
        // Commit the edits!
        editor.commit();
    }
    
    private void restorePreferences() {
        SharedPreferences settings = getPreferences(MODE_PRIVATE);
        editText1.setText(settings.getString("editText1", ""));
        editText2.setText(settings.getString("editText2", ""));
    }
    

    Call savePreferences() in onPause() if you want to save all changes by default or in an OnClickListener if it suits you better. You should call restorePreferences() in a method like onCreate() to load these values as the app starts.

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

Sidebar

Related Questions

Basically I want to read and write to a file then save all the
Basically, I want to save a certain DOM element of my page as an
I want to create own filetype to save objects in my app. Basically, I
I have a class like this that I want to save in ViewState for
I have a save button that should basically create a new entry in my
I want to write a unit test that basically verifies an object I add
I have an ASP Image control that I want to save to a specific
Basiclly I just want to capture audio and save it to a file on
Basiclly, I want to capture audio/video. Run it through a mp4 muxer and save
I have: WriteableBitmap bmp; I basicly want to save it into a file on

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.