Help with Stored variables!

Hi Thunkable Community and Support,

I’m really stuck with stored variables and it seems to be a bug. image

As per the function above the app must go to the AppTour view when the app is opened for the first time (stored variable runCount is not initialised) and the app must go to the Home view when the app is opened for 2nd time or more.

This function works perfectly well when I preview this on Thunkable Preview app (on my mobile device), however this does not work when I download the APK file. To explain this in detail consider this:

After execution of function for the first time, when I check the value of stored variable:

  • On Thunkable Preview value is 1
  • On APK value is 3

Please help!

Hey @shiv1512 :wave:

Thanks tor the question! What are I initializing your stored variable as?

And where are you calling the setPath function?

Hey @domhnallohanlon,

I’m not initialising the stored variable before it’s called in this function. If I understand correctly only ‘app’ variables can be initialised, right? The setPath function is called when the app’s splash screen loads. Below is the snapshot of what I’m saying.


Hi @shiv1512,

you should initialize all “stored” variables before using them for the first time. If not, their value is “null” and when you use them, a compare like “stored runCount > 1” may crash the app. I use the following blocks to initialize stored variables:

Later when you use a stored variable like “UserEmail”, its value will be stored and is persistent. My block is really only for the very first usage, but necessary in APK and I think in iOS.

Hi @Michael_Rogulla,

Thanks for sharing this. I did as you mentioned, however, the core problem is not resolved. When I run the app for the first time:

  • On Thunkable Preview value is 1.
  • On APK value is 3.


PS: While installing the APK I’m always deleting the previously installed APK as well.

Hi, I think that “stored” means, the variable is stored onto your smartphone. I don’t know if the “Preview button” sees your thunkable account as an individual device, maybe it always initializes everything. That is something only a developer can answer.

PS at which point is the value “3” displayed? I cannot see any block for output.

The variable is indeed stored into the device, however I read in another thread that once the app is deleted all the associated app data is also deleted.

I have a separate “debug” screen which I am using to check values for all the variables.

Can you reproduce this bug and share a link or share the link to the app you’re working on?