how do i read from firebase into app inventor into individual spots?

Skip to first unread message

Nick Betti

Dec 19, 2019, 8:22:54 PM12/19/19
to MIT App Inventor Forum

totally new to this site and app development in general i have been teaching myself for a couple weeks now been looking around for a few days now to a solution to my issue

overall plan is to create an app for my work that will allow me to scan items to make an order rigt now ive been trying to get the databasing stuff down

i figured out how to read and write to the Firebase database but the read part isnt quite working that well

* i want to retrieve data from the database and insert or assign it into individual textboxes and or labels *

attached are screenshots of the designer view, codeblocks and firebase page. also i have included the .aia file as well

any help would be greatly appreciated! lemme kno if more inf is needed

thank you so much in advance!

dropbox link for AIA file



Dec 19, 2019, 10:04:57 PM12/19/19
to MIT App Inventor Forum
In your Firebase .GotData event, you have to
apply a text Contains test to the incoming tag,
looking for the suffixes you added when you wrote the data.
You will need a separate if/then test per label.


Nick Betti

Dec 19, 2019, 10:33:58 PM12/19/19
to MIT App Inventor Forum
fast and furious response abe i love it!!! thank you so much
when you say gotData are you referring to the getValue under the when function?

for example
call database.getValue...
if text fron getValue contains [suffix]
then set dataName.text to


after looking at examples for days i thought i could have figured this out by now
i feel like there was a simpler example somewhere i came across that didnt need so many store and get value calls

somehow treating the database like a spreadsheet in a way ??

my first goal im trying to reach with this app is a customer database
with a GUI showing a place to enter the customer name and a bunch of other empty fields like phone fax email addy etc.. and when a salesperson enters a customer name then those fields would be populated automatically

which i thought would work with the databade name being customers and each customer name being a tag and each tag would have the multiple values under that ...

like rows on a spreadsheet

unless im thinking completely wromg since im so new to this

sorry for the ramblings
maybe you have more advice or can point me in the right direction to develop this sales tool

thanks again


Dec 20, 2019, 4:21:18 AM12/20/19
to MIT App Inventor Forum
Yes, if you save your customer data as a list to one tag, you can then call that data all back as one and populate labels/textboxes

Your firebase should look like this:

Storage Bucket
    Customer1: name,address,tel, mobile, email
    Customer2: name,address,tel, mobile, email
    Customer3: name,address,tel, mobile, email

In App Inventor, for example, to get Customer1 data back, call for the tag:



Dec 20, 2019, 8:32:58 AM12/20/19
to MIT App Inventor Forum

You have fallen into the trap of expecting instant gratification from a remote

Only in the .GotData event can you see the result of a remote data read,
never immediately after asking for the data from the database.

for an example from an app built around a student test score database.
(Thread still in progress)

salient points:

  • global variables to pass the different data out of the .GotData event to other parts of the app
  • IF/THEN/ELSE tree of tests against the tag prefix/suffix to ID the received datum


Message has been deleted

Nick Betti

Dec 20, 2019, 9:22:45 AM12/20/19
to MIT App Inventor Forum
@timai thanks so much for the advice 
im going to make some adjustments and try all these things out 

this is really exciting and im loving the learning process 

ill get back to you guys asap 

im also going to try and come up with all the designer views for the app im going for 
that way i can show you and better expain all the things i might need help with 

Nick Betti

Dec 20, 2019, 9:24:21 AM12/20/19
to MIT App Inventor Forum
preciate the tips ABG
im going to try them out today asap and let you guys know the progress 
as i replied to TimAI 
i will get you guys more info and screenshots asap

thank you all so much!

Nick Betti

Dec 20, 2019, 9:07:41 PM12/20/19
to MIT App Inventor Forum
good evening!!
here is an update on the progress ive made over the last few hours 
tons of researching trying successing and lots of failing 

and im here stuck once again trying to get the data to repopulate the fields

a user should be able to type in the required data in ALL fields and hit store 
that part works no problem 
they should also be able to type in just a name and hit get to repopulate the fields according to the name entered 

i have attached all the necessary stuff 
including a screenshot from the phone im testing on, showing the screen right after entering a name and hitting get button 

hoping i just overlooked something silly 
but not sure after all the info ive dredged thru tonight hahahah

thank you!





testFirebaseDB_Demo (1).aia


Dec 21, 2019, 6:03:01 AM12/21/19
to MIT App Inventor Forum
Try the attached.

You don't need the Get From TempDB button as the Customer List listpicker does all the work

I used list manipulation to pull back the values for each customer

It could all probably be better, but should work as you described


Dec 21, 2019, 7:55:13 AM12/21/19
to MIT App Inventor Forum
You could also tidy up your "store" blocks, the list isn't needed
(note: I have changed the view of some of the blocks using External Input/Internal Input from the right click menu)

Nick Betti

Dec 21, 2019, 5:30:20 PM12/21/19
to MIT App Inventor Forum
thats perfect! i have seen different views of blocks like that 
horizontal as opposed to vertical 
been meaning to look up how to do that 

thank you so much for your time and input on my project 
and sorry for the late response 
im in the middle of moving to a new house 

side question ... is there any where on theforums to post about an ongoing project and updates 
as opposed to this single question about my project that ive asked you guys?

thank you again 
and i will post back soon once i have tried your advice!

Nick Betti

Dec 21, 2019, 6:42:13 PM12/21/19
to MIT App Inventor Forum
just a thought i had now 

in regards to the "Get from TempDB" button 

while there is the list to choose from ... if someone wanted to type in a name or partial name 
instead of scolling through a, what will become a lengthy list

would i be able to incorporate the button along with the list ability as well?

asking the question now but i fully intend to try to make it work myself before you might respond 
im here to learn not to be handed anything for nothing 

thank you in advance!


Dec 21, 2019, 10:57:26 PM12/21/19
to MIT App Inventor Forum
type in a name or partial name 
instead of scolling through a, what will become a lengthy list

You can use various tests in selection procedures, like text Contains.


Nick Betti

Dec 22, 2019, 1:02:24 AM12/22/19
to MIT App Inventor Forum
awesome tip and tutorial ABG!
thank you so much !

im going to study this and try to put it into action in my projects
ill post some results tomorrow (rather later today) soon as i can 

thank you again for your advice!

Nick Betti

Dec 22, 2019, 3:23:19 PM12/22/19
to MIT App Inventor Forum
i did some more researching and testing today 
made some changes to the project 

i started syncing a google sheet of customer data to firebase 
i adjusted the blocks in AI to match the new database name
but im getting an error with the json part of the code blocks 

see attached everything as usual 
ive been moving things around and re testing everything for an hour or so 
but cant seem to make it work 

im going to move some boxes to the new house 
but will be back at it again shortly 

take a look at your convenience and let me know what your thoughts are 
thank you all so much!!









Dec 22, 2019, 3:42:54 PM12/22/19
to MIT App Inventor Forum
Your values on firebase are not properly encoded


AccNum: 126

should be

AccNum: "\"126\""

therefore things are not coming back as a properly formed json

How did you add your data from the spreadsheet ?

Nick Betti

Dec 22, 2019, 4:05:56 PM12/22/19
to MIT App Inventor Forum
oh i see what you mean 
i wonder how that came to be 

see screen shots of the google sheet and the script to sync to firebase






Dec 22, 2019, 5:55:51 PM12/22/19
to MIT App Inventor Forum
You try to decode JSON, but it is not JSON.

JSON uses colons, not = signs.
It also wraps text with " "

Go back and fix your loading procedure .



Nick Betti

Dec 22, 2019, 6:37:58 PM12/22/19
to MIT App Inventor Forum
got it ABG 
ill have to do alot more research on JSON 
and the loading procedures and such 
i have no experience with that at this time 
just the snippets ive found so far to get to where i am 


Nick Betti

Dec 22, 2019, 10:56:17 PM12/22/19
to MIT App Inventor Forum
quick update is that there is no update 
after hours of researching and testing things
i have not been able to make any progress 

apologies ABG but i havent figured out how to fix my loading procedure 
not sure how to integrate code into my already existing google sheet script editor code to make the data json formatted

ill be back at it again tomorrow trying to keep expanding my knowledge 
thanks again for everyones help 

hopefully i will have better news tomorrow 


Dec 23, 2019, 10:52:53 AM12/23/19
to MIT App Inventor Forum
I've been wondering why you are using both Google sheets and FirebaseDB
in this project.

There are ways to get to the data directly in Google Sheets from AI2.
See the Google Sheets section of FAQ

Nick Betti

Dec 25, 2019, 6:17:04 PM12/25/19
to MIT App Inventor Forum
sorry for the delayed response
between the holidays work and moving to a new houseits been crazy

thanks for the link ABG 
im checking it out now 

nothing has changed since my last post
i cannot find a way to get the slashes and quotes around my data when i import to firebase from google sheets
ive started researching mySql for a solution 
but im going to check out your suggestions now first ABG 

thanks again and merry xmas to all!!

Ill be sure to get you guys an update asap 


Dec 25, 2019, 9:21:19 PM12/25/19
to MIT App Inventor Forum


Dec 26, 2019, 11:02:11 AM12/26/19
to MIT App Inventor Forum

Nick Betti

Jan 7, 2020, 5:54:36 PM1/7/20
to MIT App Inventor Forum
hey guys!!!

apologies for the delay in getting back to you 
Tim - i tried going through almost all of those howtos and just couldnt get the results i needed
ABG - same thing hahaha

were done moving and ive had some time to do more testing research and ALOT of learning 
ive gotten much better at thinking logically to solve issues that come 
to the point where im working out problems on my own without having to search the web

to the point then...
ive made a good amount of progress towards my first goal of getting a working sales app made
i decided to use airtables and its working out great 

i am going to mark this as complete and wanted to thank you for all your help and advice!
if anyone is interested in the progress ive made or just curious to see screenshots or get the aia file 
just let me know 

thanks again and happy new year!


Jan 8, 2020, 8:41:18 AM1/8/20
to MIT App Inventor Forum
We are moving!
For future questions please sign up and use the new community here:
Reply all
Reply to author
0 new messages