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 Detail

      • set

        void set​(@Nonnull
                 String key,
                 int value)
        Set an int.
        Parameters:
        key - the key
        value - the value
      • set

        void set​(@Nonnull
                 String key,
                 long value)
        Set a long.
        Parameters:
        key - the key
        value - the value
      • set

        void set​(@Nonnull
                 String key,
                 float value)
        Set a float.
        Parameters:
        key - the key
        value - the value
      • set

        void set​(@Nonnull
                 String key,
                 double value)
        Set a double.
        Parameters:
        key - the key
        value - the value
      • set

        void set​(@Nonnull
                 String key,
                 boolean value)
        Set a boolean.
        Parameters:
        key - the key
        value - 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 key
        defaultValue - 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 key
        defaultValue - 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 key
        defaultValue - 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 key
        defaultValue - 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 key
        defaultValue - 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 key
        defaultValue - 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 key
        defaultValues - the default values
        Returns:
        the string set
      • getStringSet

        @Nullable
        Set<String> getStringSet​(@Nonnull
                                 String key)
        Get a string set or null, if the set does not exist.
        Parameters:
        key - the key
        Returns:
        the string set or null, if the set does not exist.