Shared Preference
Shared Preferences allow you to save and retrieve data in the form of key,value pair.
Shared preferences call a method getSharedPreferences() that returns a SharedPreference instance pointing to the file that contains the values of preferences.
The first parameter is the key and the second parameter is the MODE.
Preference Access Three API to Choose.
Methods of Shared Preference
getPreferences()used from within your Activity, to access activity-specific preferences.
getSharedPreferences()
used from within your Activity (or other application Context), to access application-level preferences.
getDefaultSharedPreferences()
used on the PreferenceManager.
What is Mode ?
mode is the operating mode.
Listout Mode to Apply on Preference.
MODE_PRIVATE
This is default mode, where the created file can only be accessed by the calling application.
MODE_WORLD_READABLE
This mode allow other application to read the preferences.
MODE_WORLD_WRITEABLE
This mode allow other application to write the preferences.
MODE_MULTI_PROCESS
This method will check for modification of preferences even if the Shared Preference instance has already been loaded.
MODE_APPEND
This will append the new preferences with the already existing preferences.
MODE_ENABLE_WRITE_AHEAD_LOGGING
Database open flag. When it is set , it would enable write ahead logging by default.
0 comments:
Post a Comment