Interface Preferences
-
public interface Preferences
Inject → 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 void
clear()
Clears the preferences.boolean
getBoolean(String key, boolean defaultValue)
Get a boolean or fall back to a default.double
getDouble(String key, double defaultValue)
Get a double or fall back to a default.float
getFloat(String key, float defaultValue)
Get a float or fall back to a default.int
getInt(String key, int defaultValue)
Get an int or fall back to a default.long
getLong(String key, long defaultValue)
Get along or fall back to a default.String
getString(String key)
Get a string or null, if the string does not existString
getString(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.void
remove(String key)
Removes a value from the preferences.void
set(String key, boolean value)
Set a boolean.void
set(String key, double value)
Set a double.void
set(String key, float value)
Set a float.void
set(String key, int value)
Set an int.void
set(String key, long value)
Set a long.void
set(String key, String value)
Set a string.void
set(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
-
-