Resetting tinydb after returning to the screen

Hi there,

I start with app inventor. I almost manage to do what I want but I'm stuck on a problem and I can't find the solution even with the debug.
Here is the problem:
I have values initialized only once in screen 1. If I go to screen 2, values of tinydb are modified and I want to use its parameters in screen 1.
When I return to screen 1, the values are reset (I know this because if I disable the first storevalue.redblue blocks ... it works).

Any help would be appreciated

How do you switch screens? If you use the manager screen method, you will have to read the data in the OtherScreenClosed event after coming back to Screen1, see also

See also tip 1 here

Taifun

Thanks for answering Taifun, I will read that.

A click on a button allows you to switch to screen2 (see image). The sreen2 is a color picker which allows to change a color that I want to display in the screen1. The Ok button on screen2 allows you to go back to screen1. I put here the blocks of screen2

Switch screens correctly... use the manager screen method or the Tribblehunter method or one of its variations

See again my previous link App Inventor Tutorials and Examples: Manager Screen | Pura Vida Apps

Taifun

1 Like

Finally, I found a solution while taking my bath. I added a global variable before the if condition to test if it's a first run. Thanks to Taifun for these interesting readings

read the red error to find out, why this does not work like this in the initialization of a variable...
read the value from TinyDB directly in the if statement... no global variable necessary...
also a boolean true is not the same as a textbox with the value true, use only the boolean true or false

Unbenannt2

Taifun

1 Like