data loss in TinyDB on app restart

I have below code.
QR_Ban_tru_6.aia (84.4 KB)

When there is no internet connection, it automatically saves data to TinyDB. For one thing, when I restart the application, the data in TinyDB is lost. Can you help me see why. (I want the data not to be lost on app restart). Thanks very much.

If you are asking for help, I recommend you to make it as easy for others to be able to help you ...
You probably will get more feedback then...

which means in your case post a screenshot of your relevant blocks...

To download the aia file, upload it to App Inventor, open it, do some bug hunting for you, etc... this takes time, and most people will not do that...
Thank you.


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

1 Like

Do you see the difference between the tags you use for unsent data?

To avoid typos like this, init a global variable UNSENTDATATAG with the tag you want ('unsentData') and use that global variable for each TinyDB access (read/write) for that tag.

Also, I notice you calling a procedure

Immediately before checking some global variable for connectivity:

That online/offline status probably won't be immediately available after a web request.

Consider moving the storage of barcodes into TinyDB to the 2 events that immediately catch a failed web attempt, instead of the afterscan event.

Thank you very much, I will learn from it

Thank you very much, I have init a global variable UNSENTDATATAG as you instructed and it worked.
There's also the place "Consider moving the storage of barcodes into TinyDB to the 2 events that immediately catch a failed web attempt, instead of the afterscan event." I don't understand how blocks are implemented. Can you illustrate it for me? Have a nice day!

Your app uses Google scripting, which I have no experience with, particularly how success/failure is communicated back to the app from the script environment.

I see the need for an example of how to upload online in a mixed online/offline environment.
However, I prefer to tackle something closer to AI2 standard, the new Google Sheets component, which also lacks good samples.

Given my current schedule, that might take a week or so for me.

1 Like

Very easily....just include it in the script as a response (try/catch or other), if in the unlikely event there is a failure

The Google Sheets api is very similar, but not as flexible. The AI2 standard google sheets component failed to include the query method, which is perhaps the most useful method working with google sheets could have.

There might be a reason for this...:wink:

1 Like

Thank you very much, hope to see you soon