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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:43:16+00:00 2026-05-25T06:43:16+00:00

In this example XML Layout of a PreferenceScreen : <PreferenceScreen xmlns:android=http://schemas.android.com/apk/res/android android:key=first_preferencescreen> <CheckBoxPreference android:key=wifi

  • 0

In this example XML Layout of a PreferenceScreen:

<PreferenceScreen
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:key="first_preferencescreen">
    <CheckBoxPreference
            android:key="wifi enabled"
            android:title="WiFi" />
    <PreferenceScreen
            android:key="second_preferencescreen"
            android:title="WiFi settings">
        <CheckBoxPreference
                android:key="prefer wifi"
                android:title="Prefer WiFi" />
        ... other preferences here ...
    </PreferenceScreen>
</PreferenceScreen> 

I noticed an android:key for both PreferenceScreens (nested in each other).

I couldn’t find, however, any use for them in application code: The only keys used to access a value by program code are the ones of the actual elements: CheckBoxPreference, EditTextPreference, etc.

Can they be utilized for specifying in code “access the CheckBoxPreference that’s in this PreferenceScreen and not the other”? i.e. hierarchical access?

If not, what is the purpose of the key for a PreferenceScreen? Must it be defined? Must it be unique?

  • 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-25T06:43:17+00:00Added an answer on May 25, 2026 at 6:43 am

    It is XML attribute belonging to superclass named Preference. It is documented
    http://developer.android.com/reference/android/preference/Preference.html#attr_android:key

    The application can have some use of the key, say if it is listening to changes in particular preferences like:
    onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)

    Yes. The key purpose and value might be restricted a lot, it is certainly unique. But to define how unique and in what scope, will need more reading. (I did not look at more that just few pages of online docs)

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

Sidebar

Related Questions

I am trying to implement this example http://www.javacodegeeks.com/2011/02/android-google-maps-tutorial.html and i have followed exactly all
I've got some XML, for example purposes it looks like this: <root> <field1>test</field1> <f2>t2</f2>
I'm learning about using Custom Views from the following: http://developer.android.com/guide/topics/ui/custom-components.html#modifying The description says: Class
I have a general question regarding Android's separation of layouts into layout.xml files: My
My Android app having many buttons. My main.xml layout has three buttons. I know
I was playing with corners, and I was intrigued with this behavior. XML layout:
I have the following XML layout: <LinearLayout android:id=@+id/map_locations_list android:layout_width=300dp android:layout_height=fill_parent android:layout_marginLeft=8dp android:layout_marginTop=8dp android:layout_marginBottom=8dp android:background=@color/black_shadow
In my Android application, I add a ListView element (for example) in the main.xml
This example is from php.net: <?php function Test() { static $a = 0; echo
This example uses a StringWriter to hold the serialized data, then calling ToString() gives

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.