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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:17:59+00:00 2026-05-25T15:17:59+00:00

Hello Together I startet to write my first Android app and I tried to

  • 0

Hello Together I startet to write my first Android app and I tried to use the SharedPreferences to have the possibility to store some strings.
I can Type in different names and in the onStop() I put them into the SharedPreferences and after that i make a commit. Has someone a solution that Preferences are shown on the next Activity immediatly? Because at the moment I have to switch back to the Activity where I Typed in the names and if I immediatly switch back to the Activity where the names shall be shown they appear.

protected void onStop() {
    SharedPreferences.Editor edit = set.edit();
    for(int x=0;x<counterM;x++){
            edit.putString("playerM"+x, playersMale.get(x));
        }
    for(int x=0;x<counterF;x++){
            edit.putString("playerF"+x, playersFemale.get(x));
        }
    edit.putInt("counter", counterF + counterM);
    edit.commit();
    super.onStop();

}

and here is the onCreate() where I load the name…

protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub

    super.onCreate(savedInstanceState);
    set = this.getSharedPreferences("MY_COUNT",0);
    this.setContentView(R.layout.decisionscreen);
    Random r = new Random();
    int i = set.getInt("counter",1000);
    int x = r.nextInt(i);
    name = set.getString("playerM"+x, "no Players found");
    TextView t = (TextView)findViewById(R.id.nameView);
    t.setText(name+" "+i);
    dareButton();
    truthButton();
}

I hope someone can figure out what my problem is.

  • 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-05-25T15:18:00+00:00Added an answer on May 25, 2026 at 3:18 pm

    Try to put the shared preferences editor stuff in the onPause override. It will be called as soon as you switch the activity.

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

Sidebar

Related Questions

Hello I have problem to put together animations of two separate objects to second
I have the following problem: I would like to use footnotes together with the
In PHP, strings are concatenated together as follows: $foo = "Hello"; $foo .= "
Hello I am a big fan of Git and Hg and have to use
Hello I have the following error by git-fsck, which cannot be cleaned by git-gc
Hello I was writing a Regular Expression (first time in my life I might
I'm trying to use Ajax together with jQuery to make a little window pop
Im attempting to use Silverlight and MVC together. After creating a simple Silverlight application
I have the following DOM structure: <div id=module-main> <div id=module-crumbs> <h4>Hello</h4> </div> </div> When
Hello I am putting together a tool chain on my windows Box for Cross

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.