How to detect changes to your Android Preferences

This will demonstrate how to listen for changes to the user preferences in your app, so  that you can perform tasks depending on what the user selected/changed on the preferences screen. I have an app, with a listfragment displaying rows of text. There is also a preferences screen (SettingsActivity.java) where users can set the sorting order of the list. When users change the sort order, the list should be refreshed, to disaply the items in the new order.

» Read more

How to open a website or an app in Google Play, from preferences

It is quite easy to have a preference item in your app to link to your website, or an app in Google Play. This does not even require any additional permissions for your app. However, it would be great to make sure the user knows what happens if the presses the preference item, for example if it will open a new page in the browser. To have a preference item open a website: Just add an intent inside your preference

» Read more

How to initialize default preferences for Settings in Android

If you are using Androids settings menu to provide your users with settings, you can set default values when the application is first started. The details are explained in further details in the “Defaults” section in the documentation. However, the short version is this: In your preferences.xml file, where you specify your different setting items, use the android:defaultValue attribute to specify the settings default value. <!-- default value is a boolean --> <CheckBoxPreference android:defaultValue=

» Read more