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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:04:37+00:00 2026-06-13T13:04:37+00:00

SharedPreferences peepsScores= PreferenceManager.getDefaultSharedPreferences(GamePlayFirst.this); SharedPreferences.Editor editor =peepsScores.edit(); editor.putInt(userScore1, zero); editor.putInt(userScore2, zero); editor.putInt(userScore3, zero); editor.putInt(userScore4, zero);

  • 0
SharedPreferences peepsScores= PreferenceManager.getDefaultSharedPreferences(GamePlayFirst.this);
SharedPreferences.Editor editor =peepsScores.edit();

editor.putInt("userScore1", zero);
editor.putInt("userScore2", zero);
editor.putInt("userScore3", zero);
editor.putInt("userScore4", zero);
editor.putInt("userScore5", zero);
editor.putInt("userScore6", zero);
editor.putInt("userScore7", zero);
editor.putInt("userScore8", zero);
editor.commit();

SharedPreferences peepsScores = PreferenceManager.getDefaultSharedPreferences(this);
//tryed this
int userScore1 = peepsScores.getInt("userScore1","u");
//tryed this
userScore2 = peepsScores.getInt("userScore2","0");
//and tryed this
String userScore3 = peepsScores.getInt("userScore3","0");
String userScore4 = peepsScores.getInt("userScore4","0");
String userScore5 = peepsScores.getInt("userScore5","0");
String userScore6 = peepsScores.getInt("userScore6","0");
String userScore7 = peepsScores.getInt("userScore7","0");
String userScore8 = peepsScores.getInt("userScore8","0");

the getint method is underlined no matter what random things i change and then if i delete the first line of the recieving class peepScore is underlined im been on android dev webiste this website and all over google everything says its as easy as getInt what am i doing wrong

Ill try to figure out adding later i guess when i finaly get this im posting this for all newbs like me to see lol

  • 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-13T13:04:38+00:00Added an answer on June 13, 2026 at 1:04 pm

    Try this.

    int userScore1 = peepsScores.getInt("userScore1",0);
    

    When you use getInt then you have to return integer value if your
    value is not set in shared preference.

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

Sidebar

Related Questions

i keep getting NullPointerException on this line: SharedPreferences myPreference = PreferenceManager.getDefaultSharedPreferences(this); i ran some
In activity I load preferences like: public void LoadFontSize(){ sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); loadedFontSize =
private void submit() { SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); String listprefs = SP.getString(listprefs,1); Intent emailIntent
I am using the following code: SharedPreferences.Editor edit = mPrefs.edit(); edit.putString(UUID, UUID.randomUUID().toString()); edit.commit(); //edit.apply();
I have set up the SharedPreferences like below: Editor editor = getSharedPreferences(FileName, MODE_PRIVATE).edit(); editor.clear();
I'm using SharedPreferences to persists Object fields. Take this example: class Item { private
Do I need to call edit SharedPreferences everytime before I change the preferences and
I'm writing login capability using share preference. I use SharedPreferences.Editor::commit() to store username and
I am trying to get a SharedPreferences object from the PreferenceManager but don't want
I am using this code: SharedPreferences prefName; prefName = getSharedPreferences(PREF_NAME, MODE_PRIVATE); CharSequence c =

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.