Can not save to TinyDB

Hi group
This is a follow-up on a question I posted last month and I followed the recommendations that were made.
1: I had too many screens and as per that recommendation I redid the app from 10 screens to 3 screens
2 I made changes to some blocks to remove an error as per recommendation

After all that had been done, I still have two more issues that I can't figure out...
I start with screen 1 where I have 4 buttons. They are marked C1 to C4. When I select a button example C1 then I close screen 1 and open Screen 2. On-screen 2 I have 4 more buttons marked as Rabbit, Buck, Birds, Zebra. In screen no 3 the above-selected variables example C2 and Zebra must be carried over to screen 3 into a textbox. When clicked add on the text box the result should be like this... C2 time 23h56 - Zebra. And when I press the back button the results should be saved and that returns back to screen 1. I should be able to repeat this a few times.
The problem is when I select a button in screen 1 that selection example C3 is not carried over to screen 2 where it should be added to the selection on screen 2 and then displayed in screen 3 examples C3 time 15h31 - Rabbit. Instead of screen 3 it only shows the selection of screen 2. When I press back it does not save that selection to the list viewer but saves it in the textbox When you go back to screen 3 the result is not there. but it is in the textbox.

![App coding|690x404]

1st mistake, don't close Screen1.
And second, your blocks aren't visible.


The recommended method of switching screens in App Inventor


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

The circled part of Screen3.Initialize does not make sense.

Can you explain its intentions?

I was able to read the image by right clicking it in the browser and selecting "open image in new tab"


Hello Maruis

One noticeable issue in your code is that over a short space of time your App will have several instances of Screen1 running, which is likely to cause problems - usually the App will "lock up". Just use the close screen block. That returns the User to the Screen that launched the current Screen. If that means they are taken to, say, Screen2 and you want to take them to Screen1, you can verify this and automatically take them from 2 to 1.


Concerning your description of issues passing data from one screen to another, you are sending data inline when opening a Screen, but in the newly opened screen you do not collect that data. Also, at the same time, you have TinyDB - so you need to decide which sharing method fits best. If the data requires long term storage (it's all still there next time the App is run) then choose TinyDB. If the data is only required for the current session (is not required to be there next time the App is run), then either pass the data inline or use TinyDB temporarily and clear it before App exit.

1 Like

I have put together a very basic 3 screen example, passing values in-line, no TinyDb. You could use TinyDb to Store data, in-line to share between screens.

MultiScreensNoTinyDb.aia (8.0 KB)

Try it on your phone via the Companion.

Having done so, I think you might consider using Virtual Screens instead. Screen1 is the β€˜real’ Screen and device-sized Vertical Arrangements on it are displayed/hidden as required - they are the Virtual screens. With this set-up, there is no need to pass data between screens.

1 Like

Hi Alaqmar_Bohori, thank you for your reply... Thanks for showing me how to download blocks as images... I posted the blocks hope they are more visible now! :upside_down_face:
ABG thanks for your reply, the intentions of the circled part of Screen3. Initialize is to get the data from screen 1 and screen 2 to reflect on screen 3 in the text box. The idea is to have the result from screen 1 and screen 2 to be displayed as follows ... C1 Time 18h50 (String from screen1) Rabbit (String from screen 2)
ChrisWard... thank you for your response and thank you for that aia file. In a way, I can see what you are showing me. To clarify the app I try to create with the three screens is a reporting app for my work. When I say reporting app it's for our CCTV camera operators. Each button on screen 1 represents a camera. When the app is done and I can get it to work then there will be 40 buttons on screen 1. On-screen 2 there will be 10 buttons. The data (Selected buttons from Screen 1 and Screen 2) should show on screen 3 in list and that list can than be saved

Hi Maruis

  1. You should definitely use Virtual Screens to avoid data having to fly between them
  2. 40 buttons is extreme - a List View would be User Friendly and Fat Finger Friendly - it would also reduce the code a fair bit. Worth considering.

So here is another example - a screen with 40 buttons yet there are actually no buttons......

CAM_BUTTONS.aia (3.2 KB)

Run on your phone via Companion.

ChrisWard thank you for your patience and recommendations! :pray: I am going to follow your recommendation with the virtual screens and once I am done I will reply

Hi Maruis

Could the 10 buttons be below the 40 on the same Virtual Screen?

Hi sorry for the delay in my reply. Yes, each button represents a camera and we have 40 cameras.
I am looking to save data/inputs from the 3 screens and have them displayed on a summary screen. I started using a TinyDB to save the input from each screen. I am looking to have the saved information displayed as a list on a summary screen. Is this a feasible way of using TinyDB and accomplishing my objective? And in on the summary, the result will be like this. 15 - Tine 12h45 - Dpg

Hi Maruis

Yes it is.

It probably only needs 1 screen.

All the buttons 40 + 10 on the same screen, plus potentially 3 extra buttons:

  1. A ListPicker Component that can list the data for review
  2. Save the data to an external file if required.
  3. Clear the data and optionally archive it in a TinyDB

Food for thought?

Hi, hope all is well! Thank you for your reply. I am going to test your suggestion tonight!

What do the additional 10 buttons do Maruis?

Here is a template project, as per my description using one Screen:
CAM_BUTTONS_50.aia (3.8 KB)



Hi Maruis,

Some sound advice around the number of screens. I started my app with many screens which I thought was the way to go, thankfully @TIMAI2 came to the rescue and guided me to a virtual screen arrangement.

The principles of your app appears very much like mine and is structured data collection. Similarly, I needed various 'Screens' to gather various attributes relating to a particular entry and virtual screens was the solution.

I am guessing you may also come across other animals or attributes in the various cams? EG: Kudu, warthog etc..

Feel free to send me PM, happy to share my journey.

1 Like

Hi hope all is well, finely someone is on the same page as me! Yes, I started with virtual screens yesterday. My Internet was off since December and was waiting for a new switch. Will keep you informed on my progress of my project