{"id":346,"date":"2011-01-24T23:14:00","date_gmt":"2011-01-24T23:14:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/android-quick-preferences-tutorial.html"},"modified":"2019-12-02T16:32:45","modified_gmt":"2019-12-02T14:32:45","slug":"android-quick-preferences-tutorial","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-quick-preferences-tutorial.html","title":{"rendered":"Android Quick Preferences Tutorial"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left;\">\n<p>When developing a mobile application, a common need that arises is the one of storing user&#8217;s preferences and using them when the application starts. Since this is a recurring need, Google has created a preferences framework for us. The provided mechanism allows us to show, save and manipulate user&#8217;s preferences very easily. Furthermore, the framework has support for automatic UI creation. What I mean is, that, by declaring the type of a user preference, a user interface for manipulating these preferences is automatically generated, without having to write a single line code. How does that sound for rapid application development?<\/p>\n<p>In order to make use of the preferences framework, the first step is to extend the <a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/PreferenceActivity.html\">PreferenceActivity<\/a> class. This is just a convenience class that derives from <a href=\"http:\/\/developer.android.com\/reference\/android\/app\/ListActivity.html\">ListActivity<\/a> and allows to bootstrap the preferences UI from an XML file. Additionally, it automatically saves to <a href=\"http:\/\/developer.android.com\/reference\/android\/content\/SharedPreferences.html\">SharedPreferences<\/a> behind the scenes. Don&#8217;t forget that <a href=\"http:\/\/developer.android.com\/reference\/android\/content\/SharedPreferences.html\">SharedPreferences<\/a> is the interface responsible for accessing and modifying preference data and that we can manually manipulate it by calling the <a href=\"http:\/\/developer.android.com\/reference\/android\/content\/Context.html#getSharedPreferences%28java.lang.String,%20int%29\">getSharedPreferences<\/a> method of an <a href=\"http:\/\/developer.android.com\/reference\/android\/app\/Activity.html\">Activity<\/a>. In order to tie together our <a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/PreferenceActivity.html\">PreferenceActivity<\/a> class and the XML layout file, we use the <a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/PreferenceActivity.html#addPreferencesFromResource%28int%29\">addPreferencesFromResource<\/a> method. Thus, our <a href=\"http:\/\/developer.android.com\/reference\/android\/app\/Activity.html#onCreate%28android.os.Bundle%29\">onCreate<\/a> method is very simple and looks like this:<\/p>\n<pre class=\"brush:java\">...\n@Override\npublic void onCreate(Bundle savedInstanceState) {     \n    super.onCreate(savedInstanceState);        \n    addPreferencesFromResource(R.xml.preferences);        \n}\n...\n<\/pre>\n<p>[ulp id=&#8217;luHisu6VPL9Mt6IB&#8217;]<\/p>\n<p>This assumes that we have already created a file named \u201cpreferences.xml\u201d inside the \u201cres\/xml\u201d folder. Then, in run-time, the activity will inflate the given XML resource and add the preference hierarchy to the current preference hierarchy. This XML file has a specific format via which we define the types of the preferences. All types derive from the <a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/Preference.html\">Preference<\/a> class, which represents the basic preference UI building block and provides the <a href=\"http:\/\/developer.android.com\/reference\/android\/view\/View.html\">View<\/a> to be displayed in the activity and the association with a <a href=\"http:\/\/developer.android.com\/reference\/android\/content\/SharedPreferences.html\">SharedPreferences<\/a> object to store\/retrieve the preference data. Here are some of the most common subclasses that you can directly use:<\/p>\n<ul>\n<li><a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/CheckBoxPreference.html\">CheckBoxPreference<\/a>: Provides checkbox widget functionality. Will store a Boolean value.<\/li>\n<li><a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/RingtonePreference.html\">RingtonePreference<\/a>: Allows the user to choose a ringtone from those on the device. The chosen ringtone&#8217;s URI will be persisted as a string.<\/li>\n<li><a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/EditTextPreference.html\">EditTextPreference<\/a>: Allows for string input. Will store a string into the SharedPreferences.<\/li>\n<li><a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/ListPreference.html\">ListPreference<\/a>: Displays a list of entries as a dialog. This preference will store a string into the <a href=\"http:\/\/developer.android.com\/reference\/android\/content\/SharedPreferences.html\">SharedPreferences<\/a>.<\/li>\n<\/ul>\n<p>Also bear in mind that various preferences can be grouped into categories by using the <a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/PreferenceCategory.html\">PreferenceCategory<\/a> class, which groups <a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/Preference.html\">Preference<\/a> objects and provides a disabled title above the group.<\/p>\n<p>Let&#8217;s examine what our XML declaration file will be consisted of. We are going to have two categories. Under the first one, we will have a <a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/CheckBoxPreference.html\">CheckBoxPreference<\/a>, which will enable or disable data updates to a hypothetical application and a <a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/ListPreference.html\">ListPreference<\/a> which through which we will define how often we want updates to happen. As you might have guessed, there is a dependency between the two preferences. This can be achieved by using the <a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/Preference.html#attr_android:dependency\">android:dependency<\/a> attribute. Finally, under the second category, we will have a <a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/EditTextPreference.html\">EditTextPreference<\/a> via which a welcome message will be saved and shown when necessary. This is what the XML file looks like:<\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n\n&lt;PreferenceScreen xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"&gt;\n\n    &lt;PreferenceCategory \n        android:title=\"First Category\"\n        android:key=\"first_category\"&gt;\n        \n        &lt;CheckBoxPreference \n            android:key=\"perform_updates\"\n            android:summary=\"Enable or disable data updates\"\n            android:title=\"Enable updates\" \n            android:defaultValue=\"true\"\n        \/&gt;\n        \n        &lt;ListPreference \n            android:key=\"updates_interval\"\n            android:title=\"Updates interval\"\n            android:summary=\"Define how often updates will be performed\"\n            android:defaultValue=\"1000\" \n            android:entries=\"@array\/updateInterval\"\n            android:entryValues=\"@array\/updateIntervalValues\"\n            android:dependency=\"perform_updates\"\n        \/&gt;    \n            \n    &lt;\/PreferenceCategory&gt;\n\n    &lt;PreferenceCategory \n        android:title=\"Second Category\"\n        android:key=\"second_category\"&gt;\n\n        &lt;EditTextPreference\n            android:key=\"welcome_message\"\n            android:title=\"Welcome Message\" \n            android:summary=\"Define the Welcome message to be shown\"\n            android:dialogTitle=\"Welcome Message\"\n            android:dialogMessage=\"Provide a message\"    \n            android:defaultValue=\"Default welcome message\" \/&gt;\n\n    &lt;\/PreferenceCategory&gt;\n    \n&lt;\/PreferenceScreen&gt;\n<\/pre>\n<p>Note that for the <a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/ListPreference.html\">ListPreference<\/a>, an <a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/ListPreference.html#attr_android:entries\">android:entries<\/a> attribute is defined. We use that to load predefined values which are kept in an external XML file under the name \u201cres\/values\/arrays.xml\u201d. The \u201cupdateInterval\u201d and \u201cupdateIntervalValue\u201d entries are used from that file. These are actually key-value pairs, so the actual value stored is the one in the second list. Here is what the file looks like:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n\n&lt;resources&gt;\n\n    &lt;string-array name=\"updateInterval\"&gt;\n        &lt;item name=\"1000\"&gt;Every 1 second&lt;\/item&gt;\n        &lt;item name=\"5000\"&gt;Every 5 seconds&lt;\/item&gt;\n        &lt;item name=\"30000\"&gt;Every 30 seconds&lt;\/item&gt;\n        &lt;item name=\"60000\"&gt;Every 1 minute&lt;\/item&gt;\n        &lt;item name=\"300000\"&gt;Every 5 minutes&lt;\/item&gt;\n    &lt;\/string-array&gt;\n    \n    &lt;string-array name=\"updateIntervalValues\"&gt;\n        &lt;item name=\"1000\"&gt;1000&lt;\/item&gt;\n        &lt;item name=\"5000\"&gt;5000&lt;\/item&gt;\n        &lt;item name=\"30000\"&gt;30000&lt;\/item&gt;\n        &lt;item name=\"60000\"&gt;60000&lt;\/item&gt;\n        &lt;item name=\"300000\"&gt;300000&lt;\/item&gt;\n    &lt;\/string-array&gt;\n\n&lt;\/resources&gt;\n<\/pre>\n<p>As we explained, the persisting part of the equation is handled by the framework. In order to show you how to read the already persisted values, we will create another activity which will be launched from our main one. Let&#8217;s first see how the main activity looks like:<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.android.preferences;\n\nimport android.content.Intent;\nimport android.os.Bundle;\nimport android.preference.PreferenceActivity;\nimport android.view.Menu;\nimport android.view.MenuItem;\n\npublic class QuickPrefsActivity extends PreferenceActivity {\n    \n    @Override\n    public void onCreate(Bundle savedInstanceState) {        \n        super.onCreate(savedInstanceState);        \n        addPreferencesFromResource(R.xml.preferences);        \n    }\n    \n    @Override\n    public boolean onCreateOptionsMenu(Menu menu) {\n        menu.add(Menu.NONE, 0, 0, \"Show current settings\");\n        return super.onCreateOptionsMenu(menu);\n    }\n\n    @Override\n    public boolean onOptionsItemSelected(MenuItem item) {\n        switch (item.getItemId()) {\n            case 0:\n                startActivity(new Intent(this, ShowSettingsActivity.class));\n                return true;\n        }\n        return false;\n    }\n    \n}\n<\/pre>\n<p>Nothing special here. We just provide an options menu with only one <a href=\"http:\/\/developer.android.com\/reference\/android\/view\/MenuItem.html\">MenuItem<\/a> by using the <a href=\"http:\/\/developer.android.com\/reference\/android\/app\/Activity.html#onCreateOptionsMenu%28android.view.Menu%29\">onCreateOptionsMenu<\/a> method. When the user selects the specific item, we handle its actions inside the <a href=\"http:\/\/developer.android.com\/reference\/android\/app\/Activity.html#onOptionsItemSelected%28android.view.MenuItem%29\">onOptionsItemSelected<\/a> method and we launch a new activity using the <a href=\"http:\/\/developer.android.com\/reference\/android\/app\/Activity.html#startActivity%28android.content.Intent%29\">startActivity<\/a> method. If you want to learn more about option menus, check out my older tutorial named \u201c<a href=\"http:\/\/www.javacodegeeks.com\/2010\/12\/android-full-app-part-7-options-menus.html\">Using options menus and customized dialogs for user interaction<\/a>\u201d. More information about starting activities can be found in my tutorial \u201c<a href=\"http:\/\/www.javacodegeeks.com\/2010\/11\/android-full-app-part-5-launch-activity.html\">Launching new activities with intents<\/a>\u201d.<\/p>\n<p>Let&#8217;s now create the \u201cShowSettingsActivity\u201d. First, we have to declare it in the Android manifest file, so here what our \u201cAndroidManifest.xml\u201d file looks like:<\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n\n&lt;manifest xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\n      package=\"com.javacodegeeks.android.preferences\"\n      android:versionCode=\"1\"\n      android:versionName=\"1.0\"&gt;\n      \n    &lt;application android:icon=\"@drawable\/icon\" android:label=\"@string\/app_name\"&gt;\n        \n        &lt;activity android:name=\".QuickPrefsActivity\" android:label=\"@string\/app_name\"&gt;\n            &lt;intent-filter&gt;\n                &lt;action android:name=\"android.intent.action.MAIN\" \/&gt;\n                &lt;category android:name=\"android.intent.category.LAUNCHER\" \/&gt;\n            &lt;\/intent-filter&gt;\n        &lt;\/activity&gt;\n        \n        &lt;activity android:name=\".ShowSettingsActivity\" \/&gt;\n        \n    &lt;\/application&gt;\n    \n    &lt;uses-sdk android:minSdkVersion=\"3\" \/&gt;\n\n&lt;\/manifest&gt; \n<\/pre>\n<p>Here is the code for the activity itself:<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.android.preferences;\n\nimport android.app.Activity;\nimport android.content.SharedPreferences;\nimport android.os.Bundle;\nimport android.preference.PreferenceManager;\nimport android.widget.TextView;\n\npublic class ShowSettingsActivity extends Activity {\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n\n  super.onCreate(savedInstanceState);\n  setContentView(R.layout.show_settings_layout);\n\n  SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);\n\n  StringBuilder builder = new StringBuilder();\n\n  builder.append(\"\\n\" + sharedPrefs.getBoolean(\"perform_updates\", false));\n  builder.append(\"\\n\" + sharedPrefs.getString(\"updates_interval\", \"-1\"));\n  builder.append(\"\\n\" + sharedPrefs.getString(\"welcome_message\", \"NULL\"));\n\n  TextView settingsTextView = (TextView) findViewById(R.id.settings_text_view);\n  settingsTextView.setText(builder.toString());\n\n }\n\n}\n\n<\/pre>\n<p>Inside the activity, we take reference of the <a href=\"http:\/\/developer.android.com\/reference\/android\/content\/SharedPreferences.html\">SharedPreferences<\/a> class by using the static method <a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/PreferenceManager.html#getDefaultSharedPreferences%28android.content.Context%29\">getDefaultSharedPreferences<\/a> of the <a href=\"http:\/\/developer.android.com\/reference\/android\/preference\/PreferenceManager.html\">PreferenceManager<\/a> class. Then, depending on the data type of the preference, we use the appropriate getter method, such as <a href=\"http:\/\/developer.android.com\/reference\/android\/content\/SharedPreferences.html#getBoolean%28java.lang.String,%20boolean%29\">getBoolean<\/a> or <a href=\"http:\/\/developer.android.com\/reference\/android\/content\/SharedPreferences.html#getString%28java.lang.String,%20java.lang.String%29\">getString<\/a>. Note that the second argument to those is a default value which will be used if a a value has not yet been stored. We use as keys those defined in the original \u201cpreferences.xml\u201d file, i.e. \u201cperform_updates\u201d, \u201cupdates_interval\u201d and \u201cwelcome_message\u201d. The values are concatenated and then presented in a <a href=\"http:\/\/developer.android.com\/reference\/android\/widget\/TextView.html\">TextView<\/a>.<\/p>\n<p>Here is also the simple layout for the specific activity:<\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n\n&lt;LinearLayout \n    xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\n    android:orientation=\"vertical\"\n    android:layout_width=\"fill_parent\"\n    android:layout_height=\"fill_parent\"\n    &gt;\n    \n    &lt;TextView\n        android:id=\"@+id\/settings_text_view\"\n        android:layout_width=\"fill_parent\" \n        android:layout_height=\"wrap_content\"\n    \/&gt;\n    \n&lt;\/LinearLayout&gt;\n<\/pre>\n<p>If we now launch the Eclipse configuration, we will get a preferences screen like the following:<\/p>\n<p><a href=\"http:\/\/4.bp.blogspot.com\/_piNjpdpJZXA\/TR3ORS_j9vI\/AAAAAAAAAPE\/Lx3fee9A2qA\/s1600\/01-prefs-screen.png\"><img decoding=\"async\" class=\"alignnone\" style=\"cursor: pointer; height: 320px; margin: 0px auto 10px; text-align: center; width: 299px;\" src=\"http:\/\/4.bp.blogspot.com\/_piNjpdpJZXA\/TR3ORS_j9vI\/AAAAAAAAAPE\/Lx3fee9A2qA\/s320\/01-prefs-screen.png\" alt=\"preferences screen\" width=\"299\" height=\"320\" border=\"0\"><\/a><\/p>\n<p>Clicking on the \u201cUpdates Interval\u201d will cause a list of options to appear:<\/p>\n<p><a href=\"http:\/\/4.bp.blogspot.com\/_piNjpdpJZXA\/TR3OqCH8aFI\/AAAAAAAAAPc\/j4P4wnugR_E\/s1600\/02-list-preference.png\"><img decoding=\"async\" class=\"alignnone\" style=\"cursor: pointer; height: 320px; margin: 0px auto 10px; text-align: center; width: 215px;\" src=\"http:\/\/4.bp.blogspot.com\/_piNjpdpJZXA\/TR3OqCH8aFI\/AAAAAAAAAPc\/j4P4wnugR_E\/s320\/02-list-preference.png\" alt=\"list preferences\" width=\"215\" height=\"320\" border=\"0\"><\/a><\/p>\n<p>Similarly, clicking on the \u201cWelcome Message\u201d preference will cause an edit text to appear:<\/p>\n<p><a href=\"http:\/\/4.bp.blogspot.com\/_piNjpdpJZXA\/TR3OvB4of1I\/AAAAAAAAAPk\/PgKASm6ya-w\/s1600\/03-edit-text-preference.png\"><img decoding=\"async\" class=\"alignnone\" style=\"cursor: pointer; height: 320px; margin: 0px auto 10px; text-align: center; width: 253px;\" src=\"http:\/\/4.bp.blogspot.com\/_piNjpdpJZXA\/TR3OvB4of1I\/AAAAAAAAAPk\/PgKASm6ya-w\/s320\/03-edit-text-preference.png\" alt=\"edit text preferences\" width=\"253\" height=\"320\" border=\"0\"><\/a><\/p>\n<p>Now let&#8217;s read the already persisted values. Hit the \u201cMenu\u201d button on the emulator so that the options menu appears and choose the \u201cShow current settings\u201d item. This will launch our second activity inside which the values are read and presented as follows:<\/p>\n<p><a href=\"http:\/\/2.bp.blogspot.com\/_piNjpdpJZXA\/TR3O9zr_mYI\/AAAAAAAAAP0\/ayYuIzHtMOY\/s1600\/04-read-preferences.png\"><img decoding=\"async\" class=\"alignnone\" style=\"cursor: pointer; height: 189px; margin: 0px auto 10px; text-align: center; width: 320px;\" src=\"http:\/\/2.bp.blogspot.com\/_piNjpdpJZXA\/TR3O9zr_mYI\/AAAAAAAAAP0\/ayYuIzHtMOY\/s320\/04-read-preferences.png\" alt=\"read Preferences\" width=\"320\" height=\"189\" border=\"0\"><\/a><\/p>\n<p>That&#8217;s it guys. A quick guide on how to leverage the preferences framework provided in the SDK to rapidly manipulate user preferences in your application. You can find the Eclipse project created in this tutorial <a href=\"http:\/\/dl.dropbox.com\/u\/7215751\/JavaCodeGeeks\/AndroidQuickPreferencesTutorial\/AndroidQuickPreferencesProject.zip\">here<\/a>.<\/p>\n<p>Cheers!<\/p>\n<div style=\"margin: 0px;\"><strong><i>Related Articles :<\/i><\/strong><\/div>\n<ul>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/10\/android-full-application-tutorial.html\">\u201cAndroid Full Application Tutorial\u201d series<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/11\/boost-android-xml-parsing-xml-pull.html\">Boost your Android XML parsing with XML Pull<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/09\/android-text-to-speech-application.html\">Android Text-To-Speech Application<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/09\/android-reverse-geocoding-yahoo-api.html\">Android Reverse Geocoding with Yahoo API &#8211; PlaceFinder<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/09\/android-location-based-services.html\">Android Location Based Services Application \u2013 GPS location<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/06\/install-android-os-on-pc-with.html\">Install Android OS on your PC with VirtualBox<\/a><\/li>\n<\/ul>\n<div style=\"margin: 0px;\"><strong><i>Related Snippets :<\/i><\/strong><\/div>\n<ul style=\"text-align: left;\">\n<li><a href=\"https:\/\/examples.javacodegeeks.com\/android\/core\/preference\/prefernces-and-preferenceactivity-example\">Prefernces and PreferenceActivity example<\/a><\/li>\n<li><a href=\"https:\/\/examples.javacodegeeks.com\/android\/core\/text-to-speech\/android-text-to-speech-application\">Android Text-To-Speech Application<\/a><\/li>\n<li><a href=\"https:\/\/examples.javacodegeeks.com\/android\/core\/hardware\/sensor\/android-accelerometer-example\/\">Android Accelerometer Example<\/a><\/li>\n<li><a href=\"https:\/\/examples.javacodegeeks.com\/android\/core\/media\/audiomanager\/android-audio-manager-example\/\">Android Audio Manager Example<\/a><\/li>\n<li><a href=\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/radiogroup\/android-radiogroup-example\/\">Android RadioGroup Example<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>When developing a mobile application, a common need that arises is the one of storing user&#8217;s preferences and using them when the application starts. Since this is a recurring need, Google has created a preferences framework for us. The provided mechanism allows us to show, save and manipulate user&#8217;s preferences very easily. Furthermore, the framework &hellip;<\/p>\n","protected":false},"author":3,"featured_media":46,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[131,83],"class_list":["post-346","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android-core","tag-android-preferences","tag-android-tutorial"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Android Quick Preferences Tutorial - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn more about Android Quick Preferences? Then check out our Tutorial where we discuss the most common subclasses that you can directly use.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2011\/01\/android-quick-preferences-tutorial.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android Quick Preferences Tutorial - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn more about Android Quick Preferences? Then check out our Tutorial where we discuss the most common subclasses that you can directly use.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2011\/01\/android-quick-preferences-tutorial.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2011-01-24T23:14:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-12-02T14:32:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Ilias Tsagklis\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ilias Tsagklis\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-quick-preferences-tutorial.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-quick-preferences-tutorial.html\"},\"author\":{\"name\":\"Ilias Tsagklis\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/9a83496b285d30c61e8a674625c1350e\"},\"headline\":\"Android Quick Preferences Tutorial\",\"datePublished\":\"2011-01-24T23:14:00+00:00\",\"dateModified\":\"2019-12-02T14:32:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-quick-preferences-tutorial.html\"},\"wordCount\":1048,\"commentCount\":17,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-quick-preferences-tutorial.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"keywords\":[\"Android Preferences\",\"Android Tutorial\"],\"articleSection\":[\"Android Core\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-quick-preferences-tutorial.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-quick-preferences-tutorial.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-quick-preferences-tutorial.html\",\"name\":\"Android Quick Preferences Tutorial - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-quick-preferences-tutorial.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-quick-preferences-tutorial.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"datePublished\":\"2011-01-24T23:14:00+00:00\",\"dateModified\":\"2019-12-02T14:32:45+00:00\",\"description\":\"Interested to learn more about Android Quick Preferences? Then check out our Tutorial where we discuss the most common subclasses that you can directly use.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-quick-preferences-tutorial.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-quick-preferences-tutorial.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-quick-preferences-tutorial.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-quick-preferences-tutorial.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/android\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Android Core\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/android\\\/android-core\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Android Quick Preferences Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/9a83496b285d30c61e8a674625c1350e\",\"name\":\"Ilias Tsagklis\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/43505f28bb49f6e290c24be0b209ccc1af350f0f6587025ffd4847ef44bf6b78?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/43505f28bb49f6e290c24be0b209ccc1af350f0f6587025ffd4847ef44bf6b78?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/43505f28bb49f6e290c24be0b209ccc1af350f0f6587025ffd4847ef44bf6b78?s=96&d=mm&r=g\",\"caption\":\"Ilias Tsagklis\"},\"description\":\"Ilias is a software developer turned online entrepreneur. He is co-founder and Executive Editor at Java Code Geeks.\",\"sameAs\":[\"http:\\\/\\\/www.iliastsagklis.com\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/iliastsagklis\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/ilias-tsagklis\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android Quick Preferences Tutorial - Java Code Geeks","description":"Interested to learn more about Android Quick Preferences? Then check out our Tutorial where we discuss the most common subclasses that you can directly use.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-quick-preferences-tutorial.html","og_locale":"en_US","og_type":"article","og_title":"Android Quick Preferences Tutorial - Java Code Geeks","og_description":"Interested to learn more about Android Quick Preferences? Then check out our Tutorial where we discuss the most common subclasses that you can directly use.","og_url":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-quick-preferences-tutorial.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2011-01-24T23:14:00+00:00","article_modified_time":"2019-12-02T14:32:45+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","type":"image\/jpeg"}],"author":"Ilias Tsagklis","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Ilias Tsagklis","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-quick-preferences-tutorial.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-quick-preferences-tutorial.html"},"author":{"name":"Ilias Tsagklis","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/9a83496b285d30c61e8a674625c1350e"},"headline":"Android Quick Preferences Tutorial","datePublished":"2011-01-24T23:14:00+00:00","dateModified":"2019-12-02T14:32:45+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-quick-preferences-tutorial.html"},"wordCount":1048,"commentCount":17,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-quick-preferences-tutorial.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","keywords":["Android Preferences","Android Tutorial"],"articleSection":["Android Core"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2011\/01\/android-quick-preferences-tutorial.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-quick-preferences-tutorial.html","url":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-quick-preferences-tutorial.html","name":"Android Quick Preferences Tutorial - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-quick-preferences-tutorial.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-quick-preferences-tutorial.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","datePublished":"2011-01-24T23:14:00+00:00","dateModified":"2019-12-02T14:32:45+00:00","description":"Interested to learn more about Android Quick Preferences? Then check out our Tutorial where we discuss the most common subclasses that you can directly use.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-quick-preferences-tutorial.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2011\/01\/android-quick-preferences-tutorial.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-quick-preferences-tutorial.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-quick-preferences-tutorial.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Android","item":"https:\/\/www.javacodegeeks.com\/category\/android"},{"@type":"ListItem","position":3,"name":"Android Core","item":"https:\/\/www.javacodegeeks.com\/category\/android\/android-core"},{"@type":"ListItem","position":4,"name":"Android Quick Preferences Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/9a83496b285d30c61e8a674625c1350e","name":"Ilias Tsagklis","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/43505f28bb49f6e290c24be0b209ccc1af350f0f6587025ffd4847ef44bf6b78?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/43505f28bb49f6e290c24be0b209ccc1af350f0f6587025ffd4847ef44bf6b78?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/43505f28bb49f6e290c24be0b209ccc1af350f0f6587025ffd4847ef44bf6b78?s=96&d=mm&r=g","caption":"Ilias Tsagklis"},"description":"Ilias is a software developer turned online entrepreneur. He is co-founder and Executive Editor at Java Code Geeks.","sameAs":["http:\/\/www.iliastsagklis.com\/","https:\/\/www.linkedin.com\/in\/iliastsagklis"],"url":"https:\/\/www.javacodegeeks.com\/author\/ilias-tsagklis"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/346","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=346"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/346\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/46"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=346"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}