Ionic 3 - How use ionic local storage for save data locally in device?


#1

I’m triyng to make a introduction page that will read a QR Code, save the code and pass to another page. This will occur only the first time you open the application. When closing the app and reopen, the introduction page should not appears. So, what is my problem? I’m saving the code I read, but when I close the app and open again, the code that I had saved was lost and the introduction page appears. How do I solve this?

Solutions I’ve tried to use:

NativeStorage from @ionic-native/native-storage

IonicStorageModule from @ionic/storage

None of these solutions worked for me. The IonicStorageModule do not store any data and not returned any error when a use it. The NativeStorage worked for store data, but the saved data was not persistent, and when I close the application the data was lost.


#2

You need to save and call the data stored.

//Save data
storage.set('key', 'value');

//Get saved data
storage.get('key').then((value) => {
//your code
});