Preferences are an important aspect of the android applications. It allows users to have the choice to modify and personalize it. Preferences can be set two ways: the first method is to create the preferences.xml
file in the res/xml
directory and the second method is to set the preferences from the code. We will use the former, also the easier one, by creating the preferences.xml
file as follows:
Create the xml
directory, if it does not exit, and add the preferences.xml
file. Every preference needs the following attributes, as shown in the table:
Property |
Description |
---|---|
Used to get the preference value | |
To specify the android title | |
Summary about preferences | |
Optional, used to set the default values |
Usually, there are five different preference views, as listed in the following table: