Interface UnbluPreferencesStorage


  • public interface UnbluPreferencesStorage
    Interface which can be implemented to store the preferences of Unblu at a custom location.
    This is useful if encryption should used. Alternatively you can obtain a default implementation by calling createSharedPreferencesStorage(Context).

    IMPORTANT: If you change the custom storage, make sure you can migrate the old data to the new storage.

    • Method Detail

      • createSharedPreferencesStorage

        @NonNull
        static UnbluPreferencesStorage createSharedPreferencesStorage​(@NonNull
                                                                      android.content.Context context)
        Creates a default implementation of UnbluPreferencesStorage which stores the preferences inside the SharedPreferences of the app with mode Context.MODE_PRIVATE
        Parameters:
        context - The context of the application
        Returns:
        The default implementation using SharedPreferences
      • put

        void put​(@NonNull
                 java.lang.String key,
                 @Nullable
                 java.lang.String value)
        Stores a preference in the storage. Passing in null deletes the value.
        Parameters:
        key - The key of the preference
        value - The value for the given key
      • get

        @Nullable
        java.lang.String get​(@NonNull
                             java.lang.String key)
        Read a preference from the storage
        Parameters:
        key - The key of the preference
        Returns:
        The value for the given key. Can be null if there is no value stored for the key provided.