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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:23:11+00:00 2026-06-15T09:23:11+00:00

!! Please Help, my users are loosing data due to this, and I don’t

  • 0

!! Please Help, my users are loosing data due to this, and I don’t know what to do.

This only happens on Ice Cream Sandwich, works fine on Jelly Bean, Hoenycomb, what causes this?

Since one of my strings is just a number, would it be better to save it as a float or int??

Weird thing is that, it works fine on my acer a500 tablet, with android 4.0.3, but it doesn’t work on the emulator with 4.0.3, I’ve gotten a complaint from a user with a galaxy s3 on 4.0.4, for him is didn’t work either..

I’m saving two strings to Shared Preferences like this:

Thanks

    private static final String PREFS_NAME = "com.MY_PACKAGE.MY_APP.MY_WIDGET_PROVIDER_CLASS";
    private static final String PREF_PREFIX_KEY = "prefix_"; 
    private static final String PREF_SIZE_PREFIX_KEY = "prefix_";

...

  static void saveTitlePref(Context context, int mAppWidgetId, String text) {

        SharedPreferences.Editor editor = context.getSharedPreferences(PREFS_NAME, 0).edit();
        editor.putString(PREF_PREFIX_KEY + mAppWidgetId, text);
        editor.commit();
    }

   static void saveSizePref(Context context, int mAppWidgetId, String size) {

        SharedPreferences.Editor editor = context.getSharedPreferences(PREFS_NAME, 0).edit();
        editor.putString(PREF_SIZE_PREFIX_KEY, size);
        editor.commit();
    }


   static String loadTitlePref(Context context, int mAppWidgetId) {

        SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
        String prefix = prefs.getString(PREF_PREFIX_KEY + mAppWidgetId, null);
        // If there is no preference saved, get the default from a resource
        if (prefix != null) {
            return prefix;
        } else {
            return context.getString(R.string.appwidget_prefix_default);
        }
    }

    static String loadSizePref(Context context, int mAppWidgetId) {

        SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
        String sizeprefix = prefs.getString(PREF_SIZE_PREFIX_KEY, null);
        // If there is no preference saved, get the default from a resource
        if (sizeprefix != null) {
            return sizeprefix;
        } else {
            return "24";
        }
    }

Strings xml

<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">

    <string name="appwidget_prefix_default"></string>
    <string name="appwidget_text_format"><xliff:g id="prefix">%1$s</xliff:g></string> 
    <string name="appwidget_size_format"><xliff:g id="sizeprefix">%s</xliff:g></string>


</resources>
  • 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-15T09:23:12+00:00Added an answer on June 15, 2026 at 9:23 am

    First of all you should not believe on what is happening on emulator as it works weirdly some times.

    Your code seems fine.

    I would say that you should check the same issue on other devices and check if things work fine, because it is quite possible that there is some other issue that one of your user experienced, which ultimately deduced that things are not working fine with preferences

    I have myself experienced some cases where user says the app does not work for them even though I have tested it on the same device they were using.

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

Sidebar

Related Questions

Please help me about this issue... In my application i have calender where user
Please help me. I can't understand why this function, that uses texture memory __global__
Please help me somebody to convert unicodestring into string This is how i am
Please help me with this update query. I COMPLETELY understand how redundant this is
please help me arrange these 3 buttons horizontally like this photoshopped image: Please take
please help me. I want know about what types of flags to run an
I wonder whether someone can help me please. I've put together this page which
Please could anyone help me with this problem? The wordpress admin bar is not
Please help me to turn off user interaction. I have a custom view which
Please help me look into my simple test case: import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.RootPanel; import

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.