Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 
Product and Topic Expert
Product and Topic Expert



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.

For additional details see the JavaScript file in a project that includes this plugin at


or the JS Documentation at Kapsel EncryptedStorage API Reference.

The following steps will demonstrate this plugin.

  • Create the project.
    cordova -d create C:\Kapsel_Projects\StorageDemo StorageDemo "{\"plugin_search_path\":\"C:/SAP/MobileSDK3/KapselSDK/plugins/\"}"
    cd StorageDemo
    cordova -d platform add android

    cordova -d create ~/Documents/Kapsel_Projects/StorageDemo StorageDemo "{\"plugin_search_path\":\"/Users/i826567/SAP/MobileSDK3/KapselSDK/plugins/\"}"
    cd ~/Documents/Kapsel_Projects/StorageDemo
    cordova -d platform add ios
  • Add the enycryptedstorage plugin.
    cordova -d plugin add
  • Replace www\index.html with index.htmland run
    cordova -d prepare
    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 Promise provides some suggestions on how to work with asynchronous methods.
  • Use the Android IDE or Xcode to deploy and run the project. 
  • 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.
  • Note that as of SP03, the data vault of the Logon plugin is required by the EncryptedStorage plugin.  The Logon plugin can be initialized using a new method in SP03 called 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.

    In SP03 the encryption keys are stored in the Logon Plugin's data vault and the constructor
    new sap.EncryptedStorage(store_name)
    no longer takes a password as a parameter.  The data contained in a store created with versions prior to SP03 is not migrated to SP03.

    Note that as of SMP 3.0 SP02, 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.

    Note on Android, not more than 1 MB can be stored for a single key/value pair prior to SP03.
  • 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.

    As of SP03 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