Data can be saved into shared preferences using editor. All the primitive data types like booleans, floats, ints, longs, and strings are supported. Call editor.commit() in order to save changes to shared preferences.
editor.putBoolean(
"key_name"
,
true
);
// Storing boolean - true/false
editor.putString(
"key_name"
,
"string value"
);
// Storing string
editor.putInt(
"key_name"
,
"int value"
);
// Storing integer
editor.putFloat(
"key_name"
,
"float value"
);
// Storing float
editor.putLong(
"key_name"
,
"long value"
);
// Storing long
editor.commit();
// commit changes
No comments:
Post a Comment