I am Developing a offline Game.
I want to store data, create by the user, inside the internal storage of there phone.
Anyone can help me for how to do this please.
I am Developing a offline Game.
Hi. You can make use of ‘stored’ variables. This saves whatever value you assign to it on the device. A stored variable retains the data on the device for as long as the app is installed on the Phone. Have a look at the documentation as well: https://docs.thunkable.com/variables
If you’re only storing a few pieces of information then @dmndeklerkeb’s answer is perfect.
If you are looking to store a lot of data that has similar layouts you could look at Local DB. It’s just a spreadsheet but it’s stored locally.
You are definitely correct @eoinparkinson !
@eoinparkinson I had a doubt with LocalDB - would you mind clearing it?
Does localDB refresh itself every session?
No, LocalDB should be persistent if the app is installed on your phone.
Hope that helps!
Thank you dmndeklerkeb and eoinparkinson for helping me to solve this problem.
dmndeklerkeb, I used “app” method in variables instead of “stored” method. i will try your solution.
But I used Local DB method. But it’s not worked. only show the data that i entered in the app. user’s modifications not stored. when i close and reopen the app. the user’s data are disappeared.
may be it would happened due to not define variables as ‘stored’.
But i cannot assign a value for variables at the beginning when i set the variable type as “stored”. What should i do now?
You can assign values to a ‘stored’ variable. What I did was to store the user ID on sign in to a stored variable and then to use the values in the stored variable to populate the sign in email address and password input fields. I did this so the user does not have to enter his/her email and password each time when logging in to the app. What I did with sign up was, to clear the stored values in the stored variable to save the new successful sign up values so that the signed up user don’t have to enter his/her details when signing in.
You can therefore assign a value to a stored variable for instance when a screen starts. This will ensure the initial value is stored on the device. The stored value (Global value) is then available for use in all screens’ blocks of the app if required.
I am working it on right now.
thanks for the explanation.
So, if we want settings/data to stick around post updates, use localDB. If it’s not vital between versions, using the stored variable is the easier item to use?
I think this answers my question of how to retain settings between updates. I currently store settings in stored variables. I’ll be updating now!
@jared stored variables stay stored even through new releases. I can confirm this on Android and iOS!
perhaps this is a bug that Only i am experiencing
Maybe try replace the blocks? If that doesn’t work maybe make a post about it.
Because of i defined variables as “stored”, do i need to connect those variables with a local DB for initialize some values when the app starts.
Thus if some variable have zero values at the beginning, is that necessary to connect those variables with a local DB.
No,it is not necessary. It all depends on what you want to do. You can use the Control block When Screen Starts to initialize the value when the screen starts and a button for instance to set a new stored value, or you can set the value in the app to keep score or track of a value.
Screen starts: Stored value = 0
Button (+5) clicked: Stored value = 5
Button (+5) clicked again: Stored value = 10
Exit app: Stored value = 10
If you have used the control block when Screen Starts and the app starts again, then it will set it back to 0 again. You can override this with an if statement. If the Stored value is not empty or 0, then keep it to the latest stored value, else set it back to 0. Again, it depends on what you want to do.
A stored variable value saves that value to the device without saving it in a local DB.
It’s a nice explanation.
currently I am re-correcting my previous blocks as you explained.