Native Storage

Improve this doc

$ ionic plugin add cordova-plugin-nativestorage
$ npm install --save @ionic-native/native-storage

Repo: https://github.com/TheCocoaProject/cordova-plugin-nativestorage

Native storage of variables in Android and iOS

Usage

import { NativeStorage } from '@ionic-native/native-storage';

constructor(private nativeStorage: NativeStorage) { }

...

this.nativeStorage.setItem('myitem', {property: 'value', anotherProperty: 'anotherValue'})
  .then(
    () => console.log('Stored item!'),
    error => console.error('Error storing item', error)
  );

this.nativeStorage.getItem('myitem')
  .then(
    data => console.log(data),
    error => console.error(error)
  );

Instance Members

setItem(reference, value)

Stores a value

Param Type Details
reference string
value

Returns: Promise<any>

getItem(reference)

Gets a stored item

Param Type Details
reference string

Returns: Promise<any>

remove(reference)

Removes a single stored item

Param Type Details
reference string

Returns: Promise<any>

clear()

Removes all stored values.

Returns: Promise<any>

API

Native

General