Skip to first unread message

Jeanine Goossens

unread,
Sep 28, 2017, 10:15:18 AM9/28/17
to mitappinv...@googlegroups.com
Hello,

I am making an app in which I use a TinyDB to store values the user gets while participating in the app (this value shows how much CO2 the user has produced in his day). 
Now I have one problem: I want the user to be able to start with a clean value every day. I have been trying to use a clock or a timepicker for this problem, but it won't work for me yet.
Does anyone know how I can get my app the clean up the TinyDB value daily? (preferably every morning).
Thanks for helping!


Taifun

unread,
Sep 28, 2017, 10:29:26 AM9/28/17
to MIT App Inventor Forum
use the TinyDB.ClearAll method
Taifun
PS: I removed your email address in the subject of this thread and put a probably better subject instead...

SteveJG

unread,
Sep 28, 2017, 10:33:56 AM9/28/17
to MIT App Inventor Forum
You did not share any of your code blocks Jeanine which makes it impossible to provide you with a specific recommendation.  What you do depends on your existing code.

A very simple way to do reset the database daily is to allow the app user to clear the TinyDB using a Button.  How it is cleared using blocks depends on your existing blocks; a simple way 
to clear the entire TinyDB is to use call TinyDB1.ClearAll.   A tag can be cleared using call TinyDB.ClearTag.  

You could also use a Clock or a Timepicker; what you would do depends on exactly when you want the database to be cleared so the user can start counting CO2 with a fresh start.
Explain in more detail how this should work and provide some of your blocks and someone will provide specific advice.

Regards,
Steve

Jeanine Goossens

unread,
Sep 28, 2017, 10:35:16 AM9/28/17
to MIT App Inventor Forum
Yes, I know. 
But I don't know how to tell the app to do TinyDB.ClearAll at one specific time. Could you tell me that?

J.Goossens

Taifun

unread,
Sep 28, 2017, 12:30:39 PM9/28/17
to MIT App Inventor Forum
how I can get my app the clean up the TinyDB value daily? (preferably every morning).
what about doing this on first run on a new day?
like this:

if current date != current date stored in TinyDB
then clear TinyDB and store current date in TinyDB

Taifun

Abraham Getzler

unread,
Sep 28, 2017, 1:42:52 PM9/28/17
to MIT App Inventor Forum
Will you be wanting to see long term trends in your CO2 production?

If so, consider tags that incorporate the day in them, like YYYYMMDD,CO2
or YYYYMMDD,CH4 for other gaseous emissions.

ABG

Reply all
Reply to author
Forward
0 new messages