How could you store multiple values in Tiny DB like a list, and can variables be used as tags?

I'm fairly new to App Inventor and have just dived in, figuring it out as I went. But now I've come across a problem with Tiny DB tags.

To be straight to the point, my question is: can you use variables as a tag in order to store and retrieve data from a Tiny DB? I've been trying this and I can't get anything to work.

I got to this point because I wanted to be able to store a list in Tiny DB, but couldn't figure it out. (If you've a solution to that, then the problem will be gone) Now I am at the understanding that you can't store data structures in Tiny DB, rather only raw values. (Please, correct me if I'm wrong here) So instead, I decided to store an 'index' value, as I'll call it, in Tiny DB. Then, when I want to store a number of items into Tiny DB as if like a list, I would use the 'index' value as the tag for the new items. This way, I can increment the 'index' every time I add a new item to the Tiny DB 'list'. I've also come to the understanding that you can't use integers as tags, so I've been changing the 'index' to text using a 'join' block (just in case it doesn't handle it like text already). I thought this would work, but it hasn't. Does anyone know a good solution or would care to enlighten me on something I might be (potentially completely) misunderstanding?


The picture is an example of what I am trying to achieve, but not my actual project, since it would take too long to give the context for it.
It is rather general, but it covers everything I am trying to get to work

TinyDB can be used to store complex data structures.

Here are a couple of examples ...

You can also store dictionaries in TinyDB:

Thanks, but is there any way you (or anybody else) could provide just a small example of the few blocks which are storing a list (for example) in Tiny DB and perhaps also retrieving it. I am still unclear on this and large examples are only overwhelming.


1 Like

Yes, but what if variable get updated with new value

Yes, you can, as it is done in above example.


I had tried something this and it didn't work. My problem likely lies elsewhere then. Thank you for the explanation.

Thanks for your answer. I think my problem is something completely different as I had tried this but it didn't work.

Also, from your original image:


You cannot do this - define a variable with a tinydb get value.
You will need to "set" the variable in an event block - e.g. Screen1.Initialise

Upon trying this method, I now get an error when trying to update a list to the one stored in Tiny DB.

Wrong number of arguments for GetValue
The arguments, [tag] are the wrong number of arguments for GetValue

I can't see how I could possible have too many arguments. There is only one field for adding the tag to and I am using text exactly like your above example.
ai picure copy

Difficult to tell from just seeing the one block.

Have you refreshed/reloaded your companion app ?

I am actually unable to use the companion app and was using a build of the app instead, but I don't think that would make any differences as I have seen the error before on the app.

OK, try blocks like this then


This is pretty much just as I have tried. The steps I am trying to take are pretty much as follows:

  • I first initialise a list on the first screen.

  • I then try to update the contents of the list to the one stored in Tiny DB. If the tag doesn't exist, I just make it empty.

  • Then, if the list is empty, I save it to Tiny DB to make sure the list is now saved and the tag is made. (this step should only happen at the first time the app is opened before the list is ever populated)

  • In a different screen, I then initialise another list which I then set to the same list as the one stored in Tiny DB. Basically, I think this should just transfer the list from one screen to another using two lists which are updated to the one in Tiny DB.

  • Then, finally I try adding a new item to the list and storing it back under the same tag in Tiny DB to essentially update it.

Where I think I am running into the error is when I try to set the list on the other screen.
Everything I am doing here is under an event, most under an 'initialize screen' one.

Sorry this was so long winded. Thanks for helping so far.

Please share your test aia project

TinyDB_list_test.aia (4.9 KB)

Here it is. I will admit, I actually didn't have a test project; I was using my actual project the entire time, so I threw this together real quick.
The stupid thing is, it works fine I think. It's not perfect, but it's also a test. This file is doing almost exactly what I want my other project to do, only it doesn't work when I implement this in the real project. There must be some other problem I can't see which is causing some error.

OK, nothing much wrong with that. I edited a little bit so you do not get a comma at the beginning of your list displays.

TinyDB_list_test_revised.aia (5.3 KB)

The issue you are having must be somewhere else in your blocks ?

Yes, the problem must be resulting from something else. But, I can't see what it is, so I'll have to figure that out myself. So in other words: case closed, there was never really a problem. But thank you for the help and information anyway.