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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:08:44+00:00 2026-06-08T04:08:44+00:00

As the title suggest my problem is that some SharedPreferences I’m using are conflicting

  • 0

As the title suggest my problem is that some SharedPreferences I’m using are conflicting while the app operates, for example they seem to just be over writing each overs values, and not using their ‘key’.

Additionally once the application closes fully, force close/reboot, the file is lost completely.

Logcat shows these possible hints, but I can’t for the life of me get anything to work:

07-22 13:28:13.980: W/SharedPreferencesImpl(7905):org.xmlpull.v1.XmlPullParserException: Map value without name attribute: string
and
07-22 13:28:13.980: W/SharedPreferencesImpl(7905):  at android.app.SharedPreferencesImpl.loadFromDiskLocked(SharedPreferencesImpl.java:113)

Here is my code for the SharedPrefs:

public class SharedPrefs 
{
public static String PREF_FILE = "HangedRes";
public static String USERSCORE;
public static String EXTRAWORDS;

/////////////////////////////////////////////////////////////////

static SharedPreferences settings;
static SharedPreferences.Editor editor;

///////////////////////////////////////////////////////////////////

public static String getStringPreference(Context context, String key) 
{
    settings = context.getSharedPreferences(PREF_FILE, Context.MODE_WORLD_READABLE);

    editor = settings.edit();

    String result = settings.getString(key, null);

    return result;
}

public static void setStringPreference(Context context, String key, String value) 
{
    settings = context.getSharedPreferences(PREF_FILE, Context.MODE_WORLD_READABLE);
    editor = settings.edit();
    editor.putString(key, value);
    //editor.apply();
    editor.commit();
}

/*
public static boolean getBooleanPreference(Context context, String key) {
    settings = context.getSharedPreferences(PREF_FILE, 0);
    editor = settings.edit();

    boolean result = settings.getBoolean(key, false);
    return result;
}

public static void setBooleanPreference(Context context, String key, boolean value) 
{
    settings = context.getSharedPreferences(PREF_FILE, 0);
    editor = settings.edit();

    editor.putBoolean(key, value);
    editor.commit();
}
*/


}

Here is how I am calling those methods in my main code:

 // Get current user points and display //////////////////////////
    userScore = SharedPrefs.getStringPreference(this, SharedPrefs.USERSCORE);

    //Check if things are unlocked
    ownWords = SharedPrefs.getStringPreference(this, SharedPrefs.EXTRAWORDS);

Any help would be greatly appreciated.

  • 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-08T04:08:46+00:00Added an answer on June 8, 2026 at 4:08 am

    Oh!

    public static String USERSCORE;
    public static String EXTRAWORDS;
    

    where you initialized these keys..?? 🙂

    make it like this

    public static String USERSCORE="USERSCORE";
    public static String EXTRAWORDS="EXTRAWORDS";`
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As the title suggest, I would like to do the above. Example below: library(stringr)
Please suggest or change some suitlable title for this question as i am not
As the title may suggest, I have been using jQuery AJAX to try and
As the title suggest, I've enabled right clicks for my tableview with customized rows.
As the title suggests I am looking for a open source ERP package. While
I have an array, example below, that I am serializing into the database and
Edit1 I am not sure if the title is best for the problem so
As the title suggests, I have built an utility based app. The app consists
I've earlier heard that Firefox has a major problem with links wrapping around block
I am having some issues with throwing static member classes, as the title suggests.

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.