TinyDB: The operation select list item cannot accept the arguments


I try to store three different lists to an TinyDB using different tags. But it seems to be not possible. When the data should be read from TinyDB for 2nd and 3rd tag (when Screen2 initialize), I get this error: “The operation select list item cannot accept the arguments”. Also when I try to add additional items after restarting the app, I get the error:
“The operation add items to list cannot accept the arguments”. For the 1st tag “Bezeichnung” it works fine. Seems like it is not possible to store different tags in TinyDB? What am I doing wrong?

Thank you so much for your help!

You are not saving a list to the 2nd and 3rd tinydb tags, just a text value, no list to change the selection index with
You do not appear to be calling these two tags anywhere, except on Screen2.Initialise
You do not appear to be using Listview1 for anything, no after picking event ?
You should Close Screen2 to go to Screen1 ( if you do not switch screens correctly you will run out of memory and your app will crash
Why do you need 2 screens?

See below:

Use different screens wisely

If you decided to use different screens, then you should switch them correctly, else you will run out of memory after a while...      
The recommended method of switching screens in App Inventor
(Thanks Taifun)
Also see demo: multiscreen.aia

The problem here is caused because you are mixing different variable types.

When you initialize Screen2, TinyDB fetches that tag. However, GetValue will return a string if it finds content: it does not get automatically converted to list.
This means that the select list item raises the cannot accept the arguments error. You are trying to get an item from a string, and not from a list. And consequently, the same happens with add items to list; it fails because the variable is a string and not a list.

SOLUTION: convert when reading and writing data from and to TinyDB:

  • Use the list from csv row block with the Get Value block. This will convert all fetched data, which will be stored as a CSV row, into a list with which you can work.
  • Use the list to csv row block with the Store Value block. This converts the list into a string using CSV format, which is used later to be read.



I made this image to help understand typping

PS: I was writing my response, but @TIMAI2 was faster :sweat_smile:

My solution solves that problem


It would be instructive to apply a Do It to each of the three blocks that retrieve
from TinyDB in the Screen2.Initialize block.

See what non-list was poisoning your list operations, and where it came from.

Thank you! Of course it was not a list storing to db. It seems it was too late in the night and half of my brain was already sleeping. Such a easy mistake.
I just used 2 screens as a kind of different workspaces, only for learning and testing (I start up with AppInventor yesterday ;o) Thank you for these hints and MERY CHRISTMAS.

1 Like

salut Ralf2020, s'ils vous plait comment nous pouvons stocker les autres listes dans la même base de donnée, j'ai le meme probleme

@Raymond_Kodie start a new topic, or continue in your existing topic.