[Solved] How to save "stored" variables

Surprisingly, I couldn’t find information about a fairly basic detail: how do you save a “stored” variable? Also, where is the ‘When [variable] initializes or changes’ block shown in the link below – edit: I found it but it only works for cloud variables, not stored variables.

https://docs.thunkable.com/variables#for-app-and-stored-variables-updating-when-the-variable-initializes-or-changes

Are you trying to initialise a stored variable @tatiang?

@domhnallohanlon No, I’m trying to figure out how stored variables get saved to the device. I’d like to save a value that I can retrieve after closing the app and re-opening it. Would I have to use a cloud variable for that? If not, what is the difference between an app variable and a stored variable? Both of those seem to reset when I close and re-open an app.

When I use ‘stored’ variables, these stay constant across app sessions, even after closing the app. The ‘app’ variable is a temporary variable that should reset each time you close the app.

2 Likes

Alright, I think I made a mistake. It’s working now.

I had assumed that stored variables just save and load automatically and persist after an app is closed. That seems to be the case. What I really need is a variable that is saved to the device but can be managed through code. So that I can determine when it gets saved (or not saved).

As an aside, it looks like a Forever block only cycles every 0.1 seconds, which is pretty slow for a loop.

Could you create an entry like this in the local storage when you actually set the variable in the app?

Set stored var-> ‘yourvariablename’
Local storage
______key → save date
______value-> seconds since 1970 or month/day/hour/minute/second

Yes. I just had read in the documentation that “stored” variables were a replacement for local storage so I was thinking they worked similarly. They don’t.

Thanks for your help!

1 Like

If stored variable can replace the local storage.
And I read the docs mentioned can be saved in any data type.

How do I save a todo-list under a stored variable? I mean in the initialise part.
Thank you.

If you want to save a bunch of text strings, you can insert the text strings in a list variable and then set the stored variable to that list variable.

1 Like

Thanks ! It works :grin: