

The Android SDK includes helpful classes for getting application preferences up and running easily. The following data types are supported by the SharedPreferences class: The value would be the actual username string, such as “AndroidPowerUser123” or “Bob”Ī preference can be any of a number of different data types.The key could be a string called “UserName”.The data type of the preference could be a String.The application could have a single preference to store this information: The preference key is simply a string that uniquely identifies the preference and the value is just that: the value of that preference.įor example, your application might want to store the user’s name. The next time the user launches the application, that data will still be available.Īn individual preference is simply a key-value pair with a specific data type for the value. In other words, the application (or device, for that matter) can be started and stopped without losing the data.

By persistence, we are talking about data that persists across application lifecycle events. Shared preferences are simply sets of data values that are stored persistently. Preferences are stored as groups of key/value pairs and are available at the Activity level or shared across all of Activity classes for a given application (but not outside of the application package). The Android SDK provides helpful APIs for storing and retrieving application preferences.
#PREFEDIT DEFINITION HOW TO#
In this tutorial, you learn how to store persistent application data with shared preferences. Android applications can store data in application preferences.
