Skip to Content
Author's profile photo Daniel Van Leeuwen

Getting Started with Kapsel – Part 5 — EncryptedStorage (SP09+)



The EncryptedStorage plugin provides an asynchronous API to store key value pairs securely.  The API is based on the the web storage interface but is asynchronous in nature.  The Logon plugin also provides get and set methods that can be used to store user names, password, keys and certificates while the Encrypted Storage plugin is better suited to storing application data.

For additional details see C:\SAP\MobileSDK3\KapselSDK\docs\api\sap.EncryptedStorage.html or Using the EncryptedStorage Plugin.

The following steps will demonstrate this plugin.

  • Create the project and add the encryptedstorage plugin.
    cordova create C:\Kapsel_Projects\StorageDemo StorageDemo
    cd StorageDemo
    cordova platform add android
    cordova plugin add kapsel-plugin-encryptedstorage --searchpath %KAPSEL_HOME%/plugins
    cordova create ~/Documents/Kapsel_Projects/StorageDemo StorageDemo
    cd ~/Documents/Kapsel_Projects/StorageDemo
    cordova platform add ios
    cordova plugin add kapsel-plugin-encryptedstorage --searchpath $KAPSEL_HOME/plugins
  • Replace www\index.html with index.html or for an example that also demonstrates storing values in the Logon plugin’s data vault index2.html
  • Notice that the API is asynchronous.  This can make it a bit more challenging to work with.  The article Asynchronous JS: Callbacks, Listeners, Control Flow Libs and Promises provides some suggestions on how to work with asynchronous methods.
  • Prepare, build and deploy the app with the following command.
    cordova run android
    cordova run ios


  • If the Logging plugin is added and the log level set to debug, the messages logged by the EncryptedStorage plugin can be viewed.  The log tag it uses is SMP_ENCRYPTED_STORAGE.
  • The data vault of the Logon plugin is required by the EncryptedStorage plugin.  The Logon plugin can be initialized using the method sap.Logon.initPasscodeManager.  This is to be used instead of sap.Logon.init if the application is not registering against an SAP Mobile Platform or Gateway server and Logon plugin’s data vault is required.

    If the Logon plugin’s data vault is deleted, the EncyptedStorage plugin will also delete all storage as well.  This can occur when the user clicks the Forgot Application Passcode button on the unlock screen of the Logon plugin, if the user enters too many incorrect passcodes or if the method  sap.Logon.core.deleteRegistration is called.

  • The following are some technical details of where the data is stored on Android.
    Key value pairs are stored in a SQLLite Database.
    The database is created using local storage which can only be accessed by the application that created it.  The file is stored under /data/data/packageName and can be seen and accessed when using an emulator but not a device.


    The values and the keys stored in this SQLLite database are encrypted.  See EncryptedStorage Plugin for additional technical details on the encryption used to store the data.

Back to Getting Started With Kapsel

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Daniel Van Leeuwen
      Daniel Van Leeuwen
      Blog Post Author

      Updated for SMP 3.0 SP10 SDK

      Author's profile photo Former Member
      Former Member

      Hi, the link for index.html is broken.

      Author's profile photo Daniel Van Leeuwen
      Daniel Van Leeuwen
      Blog Post Author

      Thanks for the feedback.  The broken link should be fixed now.

      Author's profile photo Former Member
      Former Member

      If anyone gets the "Unsupported major.minor version 52.0" error, uninstall Android SDK Build-tools version 24 and install version 23.0.3 in the Android SDK Manager.

      Author's profile photo Former Member
      Former Member


      Both index.html and index2.html links are broken . Your articles are very help full and detailed but most of the sample html files seems broken and it would be very help full if you keep sample codes in the thread itself.

      Thanks and really appreciated your effort.

      Author's profile photo Dan van Leeuwen
      Dan van Leeuwen

      Please refer to the current version of the document which is available at




      Dan van Leeuwen