how to implement shared preferences in hybrid mobile application using apache cordova

2.7k Views Asked by At

I am using cordova hybrid mobile application. In that application I want to implement shared preferences in the code. I get a response from server also. How to implement the shared preferences in my application. I get the response through jquery and my file extension is .html

2

There are 2 best solutions below

2
Jay Rathod On BEST ANSWER

in cordova app you can use local storage for e.g.

window.localStorage.setItem('Username',value); //Store your values

window.localStorage.getItem('Username'); //Retrieve your values

window.localStorage.removeItem('Username'); //Remove your values
1
anmol agarwal On

Use the ng Cordova plugin.

$cordovaPreferences

Methods store(key, value, dict) Store the preference of the given dictionary and key.

fetch(key, dict) Fetch the preference by the given dictionary and key.

remove(key, dict) Remove the preference by the given dictionary and key.

show() Show the application preferences. For details on this, check how to show preference pane.