LocalStorage

Improve this doc

The LocalStorage storage engine uses the browser's local storage system for storing key/value pairs.

Note: LocalStorage should ONLY be used for temporary data that you can afford to lose. Given disk space constraints on a mobile device, local storage might be "cleaned up" by the operating system (iOS).

For guaranteed, long-term storage, use the SqlStorage engine which stores data in a file.

Usage

import {Page, Storage, LocalStorage} from 'ionic-angular';
@Page({
  template: `<ion-content></ion-content>`
});
export class MyClass{
 constructor(){
   this.local = new Storage(LocalStorage);
   this.local.set('didTutorial', 'true');
 }
}

Instance Members

get(key)

Get the value of a key in LocalStorage

Param Type Details
key string

the key you want to lookup in LocalStorage

set(key, value)

Set a key value pair and save it to LocalStorage

Param Type Details
key string

the key you want to save to LocalStorage

value string

the value of the key you're saving

remove(key)

Remove a key from LocalStorage

Param Type Details
key string

the key you want to remove from LocalStorage

clear()

Related

Storage Platform Docs

API

Native

General