How to access a value from anywhere in your app


#1

If you’re trying to store data that can be used anywhere in your app then the best approach is probably to use a stored variable. These variables can be saved on your phone for future use and are accessible from any screen.

Create your variable

In this example, a variable called counter is initialised. When the app opens it is always assigned a value of 0, so you may want to modify or remove this bit if you want persistent storage.

declare_init

Update your variable

This is probably the easiest way to update your variable…

update1

Another way to update your variable

…however you could also do something like this:

update2


#2

Actually, I meant to ask:

what is the difference between the ‘stored counter’ and 'stored “counter” ’ , apart from the fact the latter can use a variable to specify the value of the variable (and thus be vulnerable to typo)?

Is the first implementation a sub-case of the second, or does it use an entirely different mechanism that could be more optimal in terms of processing power?