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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:24:27+00:00 2026-05-27T09:24:27+00:00

I have some list preferences, but I don’t know how to save the individual

  • 0

I have some list preferences, but I don’t know how to save the individual values from the list. How do I do it? Here is what I have

http://i41.tinypic.com/dh4gvo.png

    Preference customPref = (Preference) findPreference("notificationPref");
    customPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        public boolean onPreferenceClick(Preference preference) {

            SharedPreferences customSharedPreference = getSharedPreferences(
                    "notifications", Activity.MODE_PRIVATE);
            SharedPreferences.Editor editor = customSharedPreference
                    .edit();
            editor.putString("notification",
                    "The preference has been clicked");
            editor.commit();
            return true;
        }

    });

my list click listener is only for the main item in the list preferences page, but not the items in the popup itself. How do I save the choice selected in the popup itself?

  • 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-27T09:24:28+00:00Added an answer on May 27, 2026 at 9:24 am

    This is usually automatic. In your preference screen XML, you should have something like this:

    <ListPreference android:title="@string/Title" 
        android:summary="@string/Summary"
        android:key="PreferenceKey"
        android:defaultValue="VALUE_2"
        android:entries="@array/Entries"
        android:entryValues="@array/Values" />
    

    And in your strings.xml:

    <string name="Value1">Text for value 1</string>
    <string name="Value2">Text for value 2</string>
    <string name="Value3">Text for value 3</string>
    
    <string-array name="Entries">
                <item>@string/Value1</item>
                <item>@string/Value2</item>
                <item>@string/Value2</item>
    </string-array>
    <string-array name="Values">
                <item>VALUE_1</item>
                <item>VALUE_2</item>
                <item>VALUE_3</item>
    </string-array>
    

    The “Values” array specify the (string) value saved in preferences, whereas the “Entries” array specify the text of the items displayed to the user. Each time the user select an item, its corresponding value in the “Values” array is saved to preferences under the specified key (“PreferenceKey” in this example).

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

Sidebar

Related Questions

I have dynamically created some list of RadioButtons with some values. pro grammatically I
I have some std::list<char> list_type Now I have to supply contents of the list
If I have some R list mylist , you can append an item obj
I have some filters expressed as a list of function List(MyClass => Boolean) .
I have some LINQ code that generates a list of strings, like this: var
I have some code that inserts a list item into a list... I then
We have some code which sorts a list of addresses based on the distance
I have some C structures related to a 'list' data structure. They look like
I have some financial data gathered at a List[(Int, Double)], like this: val snp
I have some code to display a long list of languages inside Rails form

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.