Search docs/

Native Storage

v2.3.2

Contents

The Native Storage plugin provides native storage of variables in Android (SharedPreferences) and iOS (UserDefaults).

Index

Classes


Classes

NativeStorage

usage:

import { NativeStorage } from '@ionic-enterprise/nativestorage/ngx';

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)
  );

clear

clear(): Promise<any>

Removes all stored values.

Returns: Promise<any>


getItem

getItem(reference: string): Promise<any>

Gets a stored item

Parameters:

Name Type Description
reference string -

Returns: Promise<any>


keys

keys(): Promise<any>

Retrieving all keys

Returns: Promise<any>


remove

remove(reference: string): Promise<any>

Removes a single stored item

Parameters:

Name Type Description
reference string -

Returns: Promise<any>


setItem

setItem(reference: string, value: any): Promise<any>

Stores a value

Parameters:

Name Type Description
reference string -
value any -

Returns: Promise<any>



Other Versions