Using Web Storage

This topic describes how you can manage application data in key-value format, using the Web storage.

Related Info


To manage application data, you can use the Web standard Web Storage API.

Use the following methods to manage the Web storage:

  • To store a key-value pair, use the setItem() method:

    localStorage.setItem('sample', 'This is just sample text.');

    If the key does not exist, it is created with the specified value. If the key already exists, its value is updated.

  • To retrieve a key value, use the getItem() method:

    var value = localStorage.getItem('sample');

    If the key does not exist, the method returns null.

  • To remove a key, use the removeItem() method:


    If the key does not exist, this method does nothing.