Official Content

The ClientStorage external object allows you to store information (pairs of key-values) locally that can be accessed from the client even without connectivity.

ClientStorageEO

You can find the ClientStorage external object in the KB Explorer within the Client module, which is in turn located within the GeneXus module.

Properties

It does not have any.

Methods

Set method

It saves the received value associated with the specified key. If it is applied consecutive times to the same key, its value is the latest assigned.

Return value None
Parameters Key:Character(20), Value:Character(20)


Notes:

  • When generating the app for iOS, this method uses the file system to store the data. Therefore, that data is not persisted if the app is uninstalled and reinstalled.
  • When generating the app for Android, the stored data is not persisted if the app is uninstalled, too. The data is kept if a new version is installed over the existing one. This is because it is saved with other local data, like cache, login information or offline database.

SecureSet method

Analogous to the Set method, but it persists encrypted data.

Return value None
Parameters Key:Character(20), Value::Character(20)


Notes:

  • When generating the app for iOS, this method uses the OS Keychain to store the data securely. Therefore, that data can persist if the app is uninstalled and reinstalled.
  • When generating the app for Android, this method saves the data using the KeyStore on Android, but is stored in the app itself.

Remove method

Deletes the stored value for the given key. If the key does not exist, the method has no effect.

Return value None
Parameters Key:Character(20)

Get method

Gets the stored value for the given key. If the key does not exist, it returns an empty string.

Return value Character(20)
Parameters Key:Character(20)

Clear method

Clears all pairs of key-values stored in the device.

Return value None
Parameters None

Events

It does not have any.

Example

This API is useful, for instance, when the application needs to save some user settings in the device.

Event 'ConfirmHomeGeolocation'
  Composite
     ClientStorage.Set('HomeGeolocation', &Geolocation)
     CustomerPanel()
  EndComposite
EndEvent

Event ClientStart
  Composite
     &Geolocation = ClientStorage.Get('HomeGeolocation')
     If not &Geolocation.IsEmpty()
          CustomerPanel()
     EndIf
  EndComposite
EndEvent

Notes

  • ClientStorage API methods apply to both Online and Offline Smart Devices applications.
  • The stored values persist even if the application is closed or the user logs off. (Note that WebSession data type expires when the app is closed.)
  • The application stores the information in the device, so you can only use this API in offline procedures and events executed on the device.
  • When the developer uses Set and SecureSet methods for the same key, the persisted value it will be associated with the last method invoked.
  • Get and Remove methods are shared with both Set methods.

Scope

Generators: Apple, Android, Angular


Last update: April 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant