Is possible to use tinydb in two or more screens?

I have used a TinyDB in one screen («screen1») to saves lists and I have no problems to recover data in this screen, but when I change to other screen («screen2» or «screen3») I find that TinyDB is empty (even if I close the application and I reopen it).
So, prior to send blocks, is possible to use TinyDB in two or more screens ?

TinyDB is a non-visible component that stores data for an app.

Apps created with App Inventor are initialized each time they run. This means that if an app sets the value of a variable and the user then quits the app, the value of that variable will not be remembered the next time the app is run. In contrast, TinyDB is a persistent data store for the app. The data stored in a TinyDB will be available each time the app is run. An example might be a game that saves the high score and retrieves it each time the game is played.

Data items consist of tags and values. To store a data item, you specify the tag it should be stored under. The tag must be a text block, giving the data a name. Subsequently, you can retrieve the data that was stored under a given tag.

You cannot use the TinyDB to pass data between two different apps on the phone, although you can use the TinyDB to share data between the different screens of a multi-screen app.

When you are developing apps using the AI Companion, all the apps using that Companion will share the same TinyDB. That sharing will disappear once the apps are packaged and installed on the phone. During development you should be careful to clear the Companion app’s data each time you start working on a new app.

Thanks for the information. I have already read it, but this does not solve my problem or answer my question.

1 Like

of course, it's possible.

Is the tag you called on another screen same?
Is the namespace on the other screen the same as the main screen?

have you tried doing like this on screen 1

and doing like this on screen 2
blocks (1)

If you have changed the namespaces of the TinyDBs the data they contain would definitely be different. Namespaces are used to separate and differentiate different databases.

I include both blocks (from 2 different screens). Sorry, but are in spanish....
Screen 1 (relevant part of the block)

Screen 2 (relevant part of the block)

Thanks for any help !!!

You can change the block language,


1 Like

What are the namespaces being used on screen1 and screen2 ?

TinyDB1 in all screens.

1 Like

I think there's a problem with namespaces

Why do you expect there is a problem with namespaces Salman? Jorge's TInyDB1 should work on both of his Screens provided he has a TinyDB object on both Screens.

@A37425 provide your Blocks in English please and / or provide an aia here (just drag it into this space) to get advice from the entire community. You say you have three Screens (screen1, screen2 ...) but your example indicates a screen is named Prova.

Basic multiscreen use of the same TInyDB1 object
passDataBetweenScreens.aia (5.5 KB)

Try it Jorge. Does the example work?

1 Like

Thanks to all.
I don't know for which reason but I have solved the problem changing the namespace to another in all screens.
Thanks again !

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.