I am using tinyDB to pass data between screens and to persistently save them.
For some reason in my quite complex app the tinyDB data in my Screen 2 did not appear in Screen1, also the data were still available when re-entering screen2.
After some trial and error I observed that explicitely setting a namespace solves the problem:
I can assure you that TinyDB is working properly, which you confirmed in the second test application. You are just doing something wrong to tell you what, you would have to share your aia file.
yes, you will have to use the same namespace in Screen1 and Screen2 to be able to get data from the same TinyDB
Namespace
Namespace for storing data.
you are correct, the documentation is not very detailed...
do you have any suggestion, how this could be explained better? I'm sure, the MIT App Inventor team is open to improvements...
As mentioned, rare thing is that when I created this test app to double-check the behavior for both screens by default the same namespace seemed to be assigned.
What could be improved for the tinyDB docu is to mention the term "namespace" at all in the description.
What is a namespace, what is it good for and perhaps what causes creation of a new namespace, e.g. in my case adding a new screen. Perhaps a hint, in doubt to specify a namespace in order to have clear relations.
The namespace defaults to the component name TinyDB. If you have TinyDB1 on one screen and TinyDB2 on the other, it won't work. In this case, change the component name or set the namespace.
I began working on this app quite long ago, the second screen was added lately. So, is it possible that my observation with having a different namespace is caused by this fact, i.e. some issue due to several AI2 updates happening over time?
This means that on Screen2 you have defined a namespace, while on Screen1 it has remained the default.
If you need more help put the aia file with the problem here. Then we will find the source of the problem.
might be that I "accidently" caused a change in Screen2's TinyDB namespace. It's the first time I'm using TinyDB, perhaps I unintentionally modified things while playing around with TinyDB.
You helped me a lot to get a clearer picture here, so for this topic I currently do not need further support.
In general I want to thank you and also Taifun for that great support!
It doesn't matter if I have 3 TinyDB instances spread across the screens, they will all act as one TinyDB instance unless I change the Namespaces.
To the Which; By changing the Namespaces of each of them, they will act as different TinyDB instances, regardless of whether they have the same name (TinyDB).