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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:39:50+00:00 2026-05-26T21:39:50+00:00

The value is saved well in SharedPreference when i push it , but it

  • 0

The value is saved well in SharedPreference when i push it , but it doesn’t show when i open another time the PreferenceActivity. It runs if i don’t put the android:entryValues , but i can’t use it cause there is some difference using distinct languages in order to see what’s the value of the prefference.

¿Any idea of what can i do?

Thanks for reading.

code:

the PreferencesMenu activity:

public class PreferencesMenu extends PreferenceActivity  
{
 @Override
 public void onCreate(Bundle savedInstanceState)
 {
     super.onCreate(savedInstanceState);
     setDefaultKeyMode(MODE_PRIVATE);

     addPreferencesFromResource(R.layout.preferences);
     getPreferenceManager().setSharedPreferencesName("Gat_Preferences");

 }
}  

some of strings.xml:

    <string-array name="menu_preference_general_order_array">
        <item>Default</item>
        <item>Alphabetical</item>
    </string-array>     
    <string-array name="menu_preference_general_order_values">
        <item>default</item>
        <item>alphabetical</item>
    </string-array>

preferences.xml layout:

<?xml version="1.0" encoding="utf-8"?>
  <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
     ...
<PreferenceCategory android:title="@string/menu_preference_general">
    <ListPreference 
        android:key="list_order"
        android:persistent="true"
        android:title="@string/menu_preference_general_order_title"
        android:summary="@string/menu_preference_general_order_description"
        android:entries="@array/menu_preference_general_order_array"
        android:entryValues="@array/menu_preference_general_order_values"/> 
    </PreferenceCategory>  
</PreferenceScreen>

mod :

I use android 2.1 , and i can’t use the new fragments preference.

  • 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-26T21:39:50+00:00Added an answer on May 26, 2026 at 9:39 pm

    You need to tell the preference API what file name you want to use before loading everything up.

    Instead of this:

     addPreferencesFromResource(R.layout.preferences);
     getPreferenceManager().setSharedPreferencesName("Gat_Preferences");
    

    Do this:

     getPreferenceManager().setSharedPreferencesName("Gat_Preferences");
     addPreferencesFromResource(R.layout.preferences);
    

    On a sidenote, don’t use R.layout.preferences. You should use R.xml.preferences, putting the file under /res/xml and not under /res/layout. It does work your way, but it’s not guaranteed to work in all API versions, since it’s not the default way of working with preferences XML files.

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

Sidebar

Related Questions

When I change and synchronize value in my app, they get saved, but the
I have a date converted to double value and saved in database. Now, I
I don't know if the title explains it very well, so here's what I'm
Well, i am having some issues with an error that i don't understand. These
I want to save a set of key, value pairs (string, int) between runs
Well, I am beginner in Android and java, but I'm trying to learn. My
Well i heard that Value attribute is just a default attribute, so i used
I have configuration values saved in an app.config . I want to create a
Why when I save a value of say 40.54 in SQL Server to a
In WPF, where can I save a value when in one UserControl, then later

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.