Save variables (Android App) - Forum

Forum Navigation
You need to log in to create posts and topics.

Save variables (Android App)

Hi everyone, I'm working on a project, and I can't get all the variables to be saved, because if the app closes accidentally or the app is not stored in the device's RAM, when opening it, it returns to zero and I really need that data to be saved safely, since it is information for work.

I saw a project that Luis attached, called LocalStorage, but I'm not sure how to implement it in my app.

I would simply need that in case the app closes, it keeps everything as it was, any suggestions? Thanks!

@ramblto you can add a Timer to save all variables each few seconds using neoLocalStorage plugin.
If you store al your variables in a single JSON object it should be quite easy to save and restore any data.

CreateEmptyObject [myData]
SetVar [myData.name] "John"
SetVar [myData.age] 22
SetVar [myData.location] "Madrid"

Then in a Timer:

neoSetItem "theData" [myData] ""

To retrieve the data (when the app starts):

neoGetItem "theData" [myData] ""

I hope it helps.

Gaev, fkapnist and asmat have reacted to this post.
Gaevfkapnistasmat