I read this documentation, which is capacitor JS provided
This is my code for storing the data in capacitor js.
/*
* this function is used for the set Value
*/
async setUser(data: any) {
await Preferences.set({
key: 'value',
value: JSON.stringify(data)
});
}
/*
* this function is used for the get-Value
*/
async getUser() {
const user: any = await Preferences.get({ key: 'value' });
this.UsersDetails = user.value;
}
This is working fine when my app is running in the background. When I trash my app in the background and call for getUser(). It's giving a null value. it's not work.
Can anyone suggest if I am missing anything, or is there any other way available to Store the data in Capacitor JS?
I haven't worked with the preferences plugin but we use this and it works fine:
https://www.npmjs.com/package/capacitor-secure-storage-plugin