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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:41:05+00:00 2026-06-14T11:41:05+00:00

I’m working my way through Sam’s Tech Yourself Android Application Development in 24 Hours

  • 0

I’m working my way through “Sam’s Tech Yourself Android Application Development in 24 Hours” and at some point my Nickname and Email settings stopped saving correctly. It now doesn’t save the Nickname at all and saves the Email to both. What have I done to cause this, and how can I fix it?

I think that these are the relevant areas of the code, but if you need more please ask.
As far as I can tell, this is still code from the book, and it used to work. Maybe a typo somewhere?

public class QuizActivity extends Activity {
public static final String GAME_PREFERENCES = "GamePrefs"; 
public static final String GAME_PREFERENCES_NICKNAME = null; //String
public static final String GAME_PREFERENCES_EMAIL = null; //String

@Override
protected void onPause() {
    super.onPause();

    EditText nicknameText = (EditText) findViewById(R.id.EditText_Nickname);
    EditText emailText = (EditText) findViewById(R.id.EditText_Email);

    String strNickname = nicknameText.getText().toString();
    String strEmail = emailText.getText().toString();

    // TODO: fix password and email saving and displaying improperly
    Editor editor = mGameSettings.edit();
    editor.putString(GAME_PREFERENCES_NICKNAME, strNickname);
    editor.putString(GAME_PREFERENCES_EMAIL, strEmail);
    editor.commit();

    Toast.makeText(QuizSettingsActivity.this, R.string.settings_saved,
            Toast.LENGTH_SHORT).show();

}

public void initNicknameEntry() {
    EditText nicknameText = (EditText) findViewById(R.id.EditText_Nickname);
    if (mGameSettings.contains(GAME_PREFERENCES_NICKNAME)) {
        nicknameText.setText(mGameSettings.getString(
                GAME_PREFERENCES_NICKNAME, ""));
    }
}

public void initEmailEntry() {
    EditText emailText = (EditText) findViewById(R.id.EditText_Email);
    if (mGameSettings.contains(GAME_PREFERENCES_EMAIL)) {
        emailText.setText(mGameSettings.getString(GAME_PREFERENCES_EMAIL,
                ""));
    }
}
  • 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-14T11:41:06+00:00Added an answer on June 14, 2026 at 11:41 am

    You must initialize these to distinct values:

    public static final String GAME_PREFERENCES_NICKNAME = "Nickname"; //String
    public static final String GAME_PREFERENCES_EMAIL = "Email"; //String
    

    Otherwise SharedPreferences cannot distinguish between the two keys and will always return the first key found.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am trying to loop through a bunch of documents I have to put
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.