Package com.castlabs.android.drm

# Class SharedPreferencesKeyStore

java.lang.Object
com.castlabs.android.drm.KeyStore
com.castlabs.android.drm.SharedPreferencesKeyStore

public class SharedPreferencesKeyStore extends KeyStore
KeyStore implementation that stores keySetIds in `SharedPreferences`. If a `Context` is passed to the constructor, the shared preferences created will always be in `Context.MODE_PRIVATE`.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `DEFAULT_PREF_NAME`
  Default name used for the shared preferences store

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SharedPreferencesKeyStore(Context context)`
  Creates a new store that persists the KeySetIds in a `Context.MODE_PRIVATE` shared preferences using the `DEFAULT_PREF_NAME`
  `SharedPreferencesKeyStore(Context context, String name)`
  Creates a new store that persists the KeySetIds in a `Context.MODE_PRIVATE` shared preferences using the given name.
  `SharedPreferencesKeyStore(SharedPreferences sharedPreferences)`
  Creates a new store that uses the given shared preferences as backend.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getLicenseKeysCount()`
  Get count of stored license keys

  ### Methods inherited from class com.castlabs.android.drm.KeyStore

  `add, delete, deleteAll, get, getAll`

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### DEFAULT_PREF_NAME

    public static final String DEFAULT_PREF_NAME
    Default name used for the shared preferences store
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### SharedPreferencesKeyStore

    public SharedPreferencesKeyStore(@NonNull Context context)
    Creates a new store that persists the KeySetIds in a `Context.MODE_PRIVATE` shared preferences using the `DEFAULT_PREF_NAME`
    Parameters:
      `context` - the context

  - ### SharedPreferencesKeyStore

    public SharedPreferencesKeyStore(@NonNull Context context, @NonNull String name)
    Creates a new store that persists the KeySetIds in a `Context.MODE_PRIVATE` shared preferences using the given name.
    Parameters:
      `context` - the context
      `name` - the name used to create the shared preferences

  - ### SharedPreferencesKeyStore

    public SharedPreferencesKeyStore(@NonNull SharedPreferences sharedPreferences)
    Creates a new store that uses the given shared preferences as backend.
    Parameters:
      `sharedPreferences` - the backend preferences that are used to persist the entries

- ## Method Details

  - ### getLicenseKeysCount

    public int getLicenseKeysCount()
    Description copied from class: `KeyStore`
    Get count of stored license keys
    Specified by:
      `getLicenseKeysCount` in class `KeyStore`
    Returns:
      count of stored keys