Hello everyone in the Mit community! I'm new to this. I'd like your help. I'm developing an app to collect information using a form. The goal is to synchronize the local Tinydb and Google Sheets in App Inventor. When there's no internet connection, the data will be saved locally in the Tinydb database, and when there's internet, it will be updated in Google Sheets. This app will be used where there's no internet connection and then synchronized with Google Sheets for analysis of the collected data.
• Could you please help me with the programming block code for the entire synchronization process?
• Perhaps you could recommend other tools I could use?
Your query is the logic.
When screen initialise
Call the procedure sendData
When button clicked to save the fomr.
If app is connected to net
Send the data to gsheet
else, call the tiny db data in a variable.
Add the form datas to this varianle
Call tinydnb data to store the data
saveData Procedure
If the app is connected with net, check tinydb data
if it is not empty
then send the value to ghseet
else alert No Offline data
The Spreadsheet component has an event that signals successful addition of a row to a sheet.
That's important for insuring your data reached Google successfully, and for throttling your uploads.
If you keep a Clock1.SystemTime milliseconds time stamp in every record you collect in TinyDB, that can serve as a high water mark for your uploads. Use it in combination with a filter on the choice of device doing the upload, which is a benefit to tracking the uploads.
I had the similar app few years back and i tried the same logic.
It works flawlessly. I didnot run for every milli seconds. Since we need net connection only at the time of upload i chkd that time alone. Then upon screen init, If net is there silently will saves the data one after another from tinydb and clears to avoid overlapping or duplicate of the form data. I used one more button to know how many datas are stored in the gsheet and another button to know whethere any offline datas available or not, simple
Exactly, I would like to see the development of blocks in an image or a simple and functional example, to guide me.
Please, thank you...
Beware of using consecutive numbers as TinyDB tags and then expecting a Get Tags list to return them in the same order.
TinyDB tags are alphabetically order strings, so
10 < 2
11 < 9
...
You might be able to fix your scheme by adding 10^9 to your tags, giving them a fixed length.
This is the logical part of the project. The save button works very well when saving data to Google Sheets.
I'm having trouble syncing this data to Tinydb and maintaining the data in both Tinydb and Google Sheets, as well as the online and offline functionality.
Please could you guide me on how to do this?
this is how i proceed in my app
On save button clicked, it saves as offline data first with counter
when net connect, it makes clock to timer
if clock timers triggers onlinesave procedure and disable clock for furhter push
when this procedure triggers, it checks offline and onlince counter. if onlinecounter is less than offline thne saveurl trigger with based online counter
when weg got success then online counter triggers.
if user clears all data will vanished
You are absolutely right! One should set number as a tag from 'for each number from' block.