Ionic 4 storage values going null on android device

I am using cordova-sqlite-plugin and @ionic/storage to locally store the data on the device. On browser I am easily getting stored values, but on the android device all values are going null. Here is my code :'name').then((val) =>{
      console.log("name is", val) = val;
      console.log('role').then((val) =>{
        console.log("role" , val)
        this.role = val;


On the android device, both values are going null whereas working fine on the browser. Thanks in advance

the code does not show setters, so difficult to say.

     submit(email, name ){
        let mail = email
        let nm = name

the role is set with string and name is set with values passed with submit() function which is called on the button click

I am getting both values on browser but not on device

You are using this Plugin right?

Then your code seems to be right, and as you said it is working on the browser.
So in order to bugfix this we would need more code. What are you doing with the variables after you got them.
Maybe your Code is going forward to fast while android is still loading the storage item?
This happened to me once. Because it takes a while to get the Item from the Device Storage you sometimes must wait for the item and then go on with your code.

Yes I am using same plugin

constructor(private storage: Storage){'name').then((val) =>{
      console.log("name is", val) = val;

    })'role').then((val) =>{
        console.log("role" , val)
        this.role = val;


I want to navigate user depending upon values stored, but for the time being I have only this much code in my ts file

Can you please run this on your device and see if values are here:'name').then((val) =>{
      alert(val); = val;
    })'role').then((val) =>{
        this.role = val;

By the way which device are you using?

Okay I will try. I am using realme 3 pro andorid 9

Does this work and display a string? If so, then you have a an async issue where you need to wait for the setter to finish before to get'stuff','My stuff')

$5 on "forgot to wait on Storage.ready()".


Sorry for the late reply. You are right, this stuff is working properly but now how do I wait? =>{
    }).then((name) => console.log('after' + name) )

I have tried something like this which is also returning null

async getName() {
    const name = await'name');
    console.log('retrieved', name);

No . Still returning null on android

How are you setting name in storage? Perhaps it’s not being set properly (or storage.ready() again) if you are still getting null

yes. I have set properly. I am getting proper values with ionic serve

The code you posted for the submit method does not include storage.ready() before storage.set()

The problem is I am setting values on another page and getting values on another. Is that the reason for await issue?

And this is why I keep insisting that people should not use storage for in-app communication. If you only use storage to communicate between this app run and the next, you never have to worry about any of this. Use a mutually injected service provider instead to communicate amongst different parts of the app.

But I want to redirect user depending upon values set. I value is set which means old user redirect to some page , if value is not set means new user redirect to details page. How can I achive this ?

Read from storage only once, at application startup, and then perform your routing accordingly.