Unlike in the standard UI layout, preference definitions are stored in the res/xml resources folder.
Each preference layout is defined as a hierarchy, beginning with a single PreferenceScreen element:
<?xml version=”1.0” encoding=”utf-8”?>
<PreferenceScreen
xmlns:android=”http://schemas.android.com/apk/res/android”>
</PreferenceScreen>
You can include additional Preference Screen elements, each of which will be represented as a selectable element that will display a new screen when clicked.
Within each Preference Screen you can include any combination of PreferenceCategory and Preference elements. Preference Category elements, as shown in the following snippet, are used to break each Preference Screen into subcategories using a title bar separator:
<PreferenceCategory
android:title=”My Preference Category”/>
A simple Shared Preferences screen
<?xml version=”1.0” encoding=”utf-8”?>
<PreferenceScreen
xmlns:android=”http://schemas.android.com/apk/res/android”>
<PreferenceCategory
android:title=”My Preference Category”>
<CheckBoxPreference
android:key=”PREF_CHECK_BOX”
android:title=”Check Box Preference”
android:summary=”Check Box Preference Description”
android:defaultValue=”true”
/>
</PreferenceCategory>
</PreferenceScreen>