Saving Date Picker Values Using TinyDB HELP!

345 views
Skip to first unread message

Mariam Khan

unread,
Mar 1, 2018, 10:59:10 AM3/1/18
to MIT App Inventor Forum
Hi! I'm creating an app that logs your dreams and how many hours you sleep a night. In the app I let the use use a date picker to choose what day they are going to log a dream and the number of hours slept. I have 3 labels that display the month, day, and year that they choose after they pick the date in the date picker. I have a tinyDB that stores the information the user inputs in to 2 textboxes, a textbox for the dream and a textbox for the amount of hours they slept. When I store the the TinyDB values, I store it by using the date picker month, day, and year as the tag for it be stored. When I go to the screen where I can call the value. I also allow the user to use a datepicker to choose the day they want to the log of their dreams. However, when I enter in the date I get an error saying something along the lines ".com.app.iventor.running.time" which isn't exactly what it says but its along the lines of what it kind of says. I can't seem to figure out how to store these dates and logs as different values and then call those values so that the user can view them. Please help I'm so confused and have been trying to figure out how to fix this for a week now. THIS IS URGENT :(

SteveJG

unread,
Mar 1, 2018, 12:27:11 PM3/1/18
to MIT App Inventor Forum
You showed no block images so any advice is a guess Mariam.

The following advice might help you solve your issue:

Have you done any basic debugging; like perhaps DoIt  ?     (explained here 
         ) so you can see what is being stored?

Get a List of all the Tags stored using  the call TinyDB.GetTags block with a Label.... perhaps  Label1.text = call TinyDB.GetTags   will show you what tags are actually being stored. You can compare that with what you think is being stored.   Be careful when calling for a specific tag.  App Inventor, for many activities, is case sensitive    a tag called   mytag is not the same as Mytag or MyTag.

The error you get might be 'runtime' error.  I don't know.  If it is a runtime error, what might be happening is what you choose in the datapicker is not fully resolving the date information before your following code executes.  This can easily happen if you are picking the date on one screen and expecting to use it on a second screen without correctly passing the values.  A reason I seldom code on more than one screen; doing so causes complications that have to be coded around.

No one has seen your actual blocks except you so no one really knows what the issue might be.

Regards,
Steve

Mariam K

unread,
Mar 1, 2018, 12:51:57 PM3/1/18
to MIT App Inventor Forum

The first image is the code for the page where you enter in the information. The second one is where I try to call the TinyDB tag but it doesn't work

Mariam K

unread,
Mar 1, 2018, 12:54:03 PM3/1/18
to MIT App Inventor Forum
Also you mentioned that this could be a problem because I am coding on more than 1 screen? How would I be able to do this one screen? 

Abraham Getzler

unread,
Mar 1, 2018, 5:16:28 PM3/1/18
to MIT App Inventor Forum
Those block images aren't enough to diagnose the problem.

Could you post the .aia export file here?

ABG

SteveJG

unread,
Mar 1, 2018, 5:18:08 PM3/1/18
to MIT App Inventor Forum
Your blocks look OK... what might cause the issue is the two calls to TinyDB in succession in your call ...DatePickerCall.AfterDateSet .  The second call to the GetValue might not be happening when you use the DatePicker  Suggestion: disable one of the blocks (perhaps NumbersSleptLabel) and its linked blocks.  Now run your app and see what happens.   That is, enter new data with the DatePicker, then immediately request it again.  Do you retrieve it?  Realize if you post to the same monthdayyear several times on the same date, the subsequent posts will overwrite the earlier because you do not capture the time.

To develop on a single screen one uses horizontal and/or vertical layouts as 'virtual screens' .  Hide a layout using the Visible property to false, display it with true.
see  






Reply all
Reply to author
Forward
0 new messages