Here are a couple of question from a reader of my appinventorapi.com blog, which focuses on app inventor apps that store/retrieve data from a web database or API. The second question specifically asks about storing multiple timestamps, e.g., if you were tracking your user’s activity or location. In general, it asks about how to store lists of data in a web database:
1. How can I check if a value is already stored in a TinywebDB ?
The only way to check for a value in the web db is to call TinyWebDB.getValue(tag). If there is no data value for the tag you send, the result in TinyWebDB.GotValue will be the empty string. You can check this by checking if the length of result is greater than 0.
2. Is it possible to store multiple arguments for one Tag at different time intervals ?(e.g.I save TAG 1, 2 and 3 right now it saves as an argument the current time of the system, then a few minutes or hours later I Save TAG 1,2 and 3 again and it puts a new a timestamp without overwriting the previous stored valued is this possible ? so at the end of the day if I check the Database I can have something like this Tag 1 (Time1, Time2, Time3, etc) for each stored value
Tinywebdb only stores one value for each tag. You can store a list as a value, however. So you could store different timestamps in a list, and store the entire list as a value of some tag. To implement this scheme, you need to load the list into your app using GetValue. Then call add item to list to add a new item (time stamp) to the list, then remember to call TinyWebDB.StoreValue to put the updated list back into the database.
For examples of storing lists of data using tinywebdb, check out the MakeQuiz/TakeQuiz sample chapter (ch 10), as well as the Database chapter (ch 22)