keywords:
Bookmark and Share



Front Back
android.content.SharedPreferences
A simple way to store some basic state information and user data.

You can access shared preferences, by name, from any activity within the application.

E.g. - public static final String GAME_PREFERENCES = "GamePrefs";
getSharedPreferences();
Used to retrieve an instance of a SharedPreferences object.
SharedPreferences.Editor
This is necessary to modify preferences.
commit()
This method is used to commit changes in the editor.
Key/Values
Each preference is stored as a key/value pair. Values can be the following types:
  • Boolean
  • Float
  • Integer
  • String
  • Long

Save two preferences - the user's name and age (Code this)
Retrieving Shared Preferences
x of y cards