|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
T - type of java object preferencepublic interface Preference<T>
Class for working with android preferences: can save and load preferences, convert them to custom java objects and use default value;
| Method Summary | |
|---|---|
T |
getDefaultValue()
|
String |
getKey()
Method returns key of preference used in android: the key with which current preference is saved in persistence |
T |
getPreference(android.content.SharedPreferences preferences)
NOTE: this method can throw runtime exceptions if errors occurred while extracting preferences values |
T |
getPreferenceNoError(android.content.SharedPreferences preferences)
NOTE: this method SHOULD not throw any runtime exceptions BUT return default value if any error occurred |
boolean |
isSameKey(String key)
|
boolean |
isSet(android.content.SharedPreferences preferences)
|
void |
putDefault(android.content.SharedPreferences preferences)
Method saves default value in preferences container. |
void |
putPreference(android.content.SharedPreferences preferences,
T value)
Method puts (saves) preference represented by value in preferences container |
boolean |
tryPutDefault(android.content.SharedPreferences preferences)
Method applies default value to preference only if explicit value is not set |
| Method Detail |
|---|
@Nonnull String getKey()
T getDefaultValue()
T getPreference(@Nonnull
android.content.SharedPreferences preferences)
preferences - application preferences
T getPreferenceNoError(@Nonnull
android.content.SharedPreferences preferences)
preferences - application preferences
void putPreference(@Nonnull
android.content.SharedPreferences preferences,
@Nullable
T value)
value in preferences container
preferences - preferences containervalue - value to be saved
void putDefault(@Nonnull
android.content.SharedPreferences preferences)
preferences container.
Should behave exactly as p.putPreference(preferences, p.getDefaultValue())
preferences - preferences container
boolean isSet(@Nonnull
android.content.SharedPreferences preferences)
preferences - preferences container
boolean tryPutDefault(@Nonnull
android.content.SharedPreferences preferences)
preferences - preferences container
boolean isSameKey(@Nonnull
String key)
key - preference key
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||