Variables that dont lost after game reset?

*fail title* Variables that aren’t lost after restart?

Hi guys,

I was wandering if there was a way to keep a variable after the game has been restarted (closed app, then re-opened). I know there are global variables, but I dont think they remain after app restarts. This would be used for checking if the player has opened the app before, or if its the first time? Or local highscores that the player has achieved?

Look into the GGData or DMC Autostore libraries.

https://developer.coronalabs.com/code/ggdata

http://developer.coronalabs.com/code/dmc-lib-auto-store

Thanks :smiley:

Apps which are suspended will remain in memory and as such will not lose their variable’s values.

Apps which are cleaned from memory will be “exited” and will lose all in-memory values.

In both situations you can listen to the Runtime for applicationN events, where N is ‘Start’, ‘Suspend’, ‘Resume’ and ‘Exit’. The API docs cover these.

If you want to store values beyond app exit you should write then to the docs, cache or temp directory. See the io.* library.

Look into the GGData or DMC Autostore libraries.

https://developer.coronalabs.com/code/ggdata

http://developer.coronalabs.com/code/dmc-lib-auto-store

Thanks :smiley:

Apps which are suspended will remain in memory and as such will not lose their variable’s values.

Apps which are cleaned from memory will be “exited” and will lose all in-memory values.

In both situations you can listen to the Runtime for applicationN events, where N is ‘Start’, ‘Suspend’, ‘Resume’ and ‘Exit’. The API docs cover these.

If you want to store values beyond app exit you should write then to the docs, cache or temp directory. See the io.* library.