Cory Pickett

unread,
Feb 16, 2016, 9:02:15 PM2/16/16
to mitappinv...@googlegroups.com
I'm trying to create an app that lets a user select phone numbers from their contacts to create a list. I want the list to be stored in the tinydb so they dont have to select the list each time the app is opened. My list picking seems to work fine, but I don't know if it's actually being stored correctly or if my tinydb is incorrect. If I close the phone number picker and open my listpicker I can see the phone numbers there, but if I leave the screen or close the app the numbers are gone.  I've created a screen initialize to recall the data from the tinydb, but it typically causes the app to crash. I'm not sure what I'm doing wrong so I'd really apprecaite some help! I've been stuck on this for a few days now. I've attached a screen shot of my blocks. Thank you in advance! I should also mention I've been following the text group 2 tutorial for most of this, but that tutorial is for app inventor classic so that might be causing a disconnect also as I'm trying to piece that tutorial together using app inventor 2
settings screen.PNG

Abraham Getzler

unread,
Feb 17, 2016, 10:38:02 AM2/17/16
to MIT App Inventor Forum
I see two errors in your screen initialization block.

When you try to retrieve a list from TinyDB,
do not accept the default value of " " that comes with the
Get from TinyDB block.
Instead, ask for an empty list (create empty list) block as the default.
This way, you don't have to poison your list operations or test list/notList.
You can jump directly into adding items to the empty list.

Your while ... is not a list loop in the screen initialize block
will never end, sending your app into catatonia.
Use an IF block instead.  You don't want to loop if the
test result will never change.
Better yet, follow the preceding paragraph advice, and you
won't have to test list/notList.

Further advice...
Your TinyDB tag "Contacts" is misleading,
since all you save under it is just phone numbers and not names?
This may come back to bite you.

ABG


Reply all
Reply to author
Forward
0 new messages