Interface Preferences
-
public interface PreferencesInject → Manage app-local preferences with a simple key-value API. On Android, the SharedPreferences are used to store the information. On iOS, the NSUserDefaults are used.- Since:
- 0.5.1
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclear()Clears the preferences.booleangetBoolean(String key, boolean defaultValue)Get a boolean or fall back to a default.doublegetDouble(String key, double defaultValue)Get a double or fall back to a default.floatgetFloat(String key, float defaultValue)Get a float or fall back to a default.intgetInt(String key, int defaultValue)Get an int or fall back to a default.longgetLong(String key, long defaultValue)Get along or fall back to a default.StringgetString(String key)Get a string or null, if the string does not existStringgetString(String key, String defaultValue)Get a string or fall back to a default.Set<String>getStringSet(String key)Get a string set or null, if the set does not exist.Set<String>getStringSet(String key, Set<String> defaultValues)Get a string set or fall back to a default.voidremove(String key)Removes a value from the preferences.voidset(String key, boolean value)Set a boolean.voidset(String key, double value)Set a double.voidset(String key, float value)Set a float.voidset(String key, int value)Set an int.voidset(String key, long value)Set a long.voidset(String key, String value)Set a string.voidset(String key, Set<String> stringSet)Set a set of strings.
-
-
-
Method Detail
-
set
void set(@Nonnull String key, @Nonnull Set<String> stringSet)
Set a set of strings.- Parameters:
key- the keystringSet- the string set
-
set
void set(@Nonnull String key, @Nonnull String value)
Set a string.- Parameters:
key- the keyvalue- the value
-
set
void set(@Nonnull String key, int value)
Set an int.- Parameters:
key- the keyvalue- the value
-
set
void set(@Nonnull String key, long value)
Set a long.- Parameters:
key- the keyvalue- the value
-
set
void set(@Nonnull String key, float value)
Set a float.- Parameters:
key- the keyvalue- the value
-
set
void set(@Nonnull String key, double value)
Set a double.- Parameters:
key- the keyvalue- the value
-
set
void set(@Nonnull String key, boolean value)
Set a boolean.- Parameters:
key- the keyvalue- the value
-
getString
@Nullable String getString(@Nonnull String key)
Get a string or null, if the string does not exist- Parameters:
key- the key- Returns:
- the string or null, if the string does not exist
-
getInt
int getInt(@Nonnull String key, int defaultValue)
Get an int or fall back to a default.- Parameters:
key- the keydefaultValue- the default value- Returns:
- the int
-
getLong
long getLong(@Nonnull String key, long defaultValue)
Get along or fall back to a default.- Parameters:
key- the keydefaultValue- the default value- Returns:
- the long
-
getFloat
float getFloat(@Nonnull String key, float defaultValue)
Get a float or fall back to a default.- Parameters:
key- the keydefaultValue- the default value- Returns:
- the float
-
getDouble
double getDouble(@Nonnull String key, double defaultValue)
Get a double or fall back to a default.- Parameters:
key- the keydefaultValue- the default value- Returns:
- the double
-
getBoolean
boolean getBoolean(@Nonnull String key, boolean defaultValue)
Get a boolean or fall back to a default.- Parameters:
key- the keydefaultValue- the default value- Returns:
- the boolean
-
remove
void remove(@Nonnull String key)
Removes a value from the preferences.- Parameters:
key- the key
-
clear
void clear()
Clears the preferences.
-
getString
@Nonnull String getString(@Nonnull String key, @Nonnull String defaultValue)
Get a string or fall back to a default.- Parameters:
key- the keydefaultValue- the default value- Returns:
- the string
-
getStringSet
@Nonnull Set<String> getStringSet(@Nonnull String key, @Nonnull Set<String> defaultValues)
Get a string set or fall back to a default.- Parameters:
key- the keydefaultValues- the default values- Returns:
- the string set
-
-