Secure Local Storage data classes
  • 26 Dec 2024
  • 1 Minute à lire
  • Sombre
    Lumière
  • PDF

Secure Local Storage data classes

  • Sombre
    Lumière
  • PDF

The content is currently unavailable in French. You are viewing the default English version.
Résumé de l’article

The following sections provide more detailed information about every class and method available in this API.

Secure Local Storage operates over the pair key, value.

The Secure Local Storage implementation is backed by files. The key-value pairs are stored in files in the directory files-dir/736869656c64/736c73/, where files-dir is the application’s private data directory which is returned by Context.getFilesDir().

For more information, refer to the developer reference documentation on getFilesDir().

The class SecureLocalStorage is the entry point to the Secure Local Storage.

class SecureLocalStorage

The class has a singleton instance which is returned by getInstance().

To save the data within Secure Local Storage you need to call put() and provide the key-value pair. The same key must be used when later reading (get()) or deleting (remove()) the data.

The key must not be null. A NullPointerException is thrown if null is passed as key to any API function.

The data to store is a byte array. To store a Java String as data you can call String.getBytes(encoding). For more information, refer to the developer reference documentation on String.

The following public methods are available in this class:

  • static SecureLocalStorage getInstance()

    This static method returns the singleton instance of SecureLocalStorage.

  • void put(String key, byte[] value)

    Stores a key-value pair. The key can be used to retrieve the value or remove the key-value pair. The key must not be null.

    The value to store may be null.

    Throws a NullPointerException if the specified key is null.

    Throws an IOException if there was an I/O error on writing the value.

  • byte[] get(String key)

    Gets the value for the specified key from the storage.

    If the there is no key-value pair with the requested key in the storage, null is returned.

    Throws a NullPointerException if the specified key is null.

    Throws an IOException if there was an I/O error on reading the value.

  • void remove(String key)

    Removes the key-value pair which is identified by the specified key from the storage.

    Throws a NullPointerException if the specified key is null.

    Throws an IOException if there was an I/O error on removing the key-value pair.


Cet article vous a-t-il été utile ?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Ozzy, facilitant la découverte de connaissances grâce à l’intelligence conversationnelle