Friday 6 February 2015

How to retrieve Data From Shared Preferences ?

Data can be retrieved from saved preferences by calling getString() (For string) method. This method should be called on Shared Preferences not on Editor.
// returns stored preference value
// If value is not present return second param value - In this case null
pref.getString("key_name"null); // getting String
pref.getInt("key_name"null); // getting Integer
pref.getFloat("key_name"null); // getting Float
pref.getLong("key_name"null); // getting Long
pref.getBoolean("key_name"null); // getting boolean

No comments:

Post a Comment