Firebase vs Lists & Listview?

The second screen of my app is to show the data rows of the Firebase database. I am not sure if I understand the ListPicker and ListView or should I just use a loop to populate the screen? The database has 8 tags, with then rows of data, each row has the tag or key of the posting data/time. See images.


tags
datarows

What is the recommended way to populate the screen?

The idea is to reconstruct the date time from the keys of the values under each leg hanging from base project bucket ( )

Remind me again, are you inputting data to the app, then sending to Firebase, or is the data in Firebase being populated by external means (e.g. arduino/sensor...)?

Will this be a single user app?

Both - some values will be added to the database from an arduino (temp, salinity, pH) will be added hourly or several times a day. The other values will be loaded via the app.

Likely a single user

From what you say, I might suggest you do something like this, which is to send the data for a measurement twice. Once to the type records, then to the "latest" tag. The last value sent will be the latest, correct?

In your app:

image

In Firebase:

image

Then if you need all the latest values you just call back the "latest" tag. If you need the history for a type, then call that tag back, or you can of course call back the whole lot.

1 Like


I am using this code that does similar to what you have.
What I am trying to figure out is how to populate the above screen. At the top I want to select which tag tree to present. and then read backwards the data.

Well, not quite the same at all...

Look again at my structure, and the top node which is aquarium (this is set as projectBucket)

To populate your display, you need to call back the tag for the selected value (create a spinner or use a popup menu extension for this).

Then you would send your get value:
e.g. as in my example
getValue: salinity

which will return all the values in the tag salinity. You would then need to process the returned json (make human readable dates from timestamps/ get the value for each) for displaying in a list.

I do not see a getValue in your example?
This is my data format.
I just added a spinner to the top of the screen. For now I am using an entered list of elements.

image


image

I setup a spinner from your tutorial.
Now I am trying to populate the rows of data. I thought I would at least get the first row with data from the getValue.

I suggest you have a look at the contents of value returned in gotValue. Add it to a label to see it .

For me, when calling alkalinity, I get a json with two sets of data (which is all there is):

{"1720704449864":"\"4\"","1720704846242":"\"4.08\""}

image

why would I add value to label vs text box?
how can I look at the json?
in C or cobol I would debug with lots of print statements to visualize what is happening

When the spinner selection (spParameter) is picked, get the tag for starting recalling the data. Do I need to refocus the pocket?

I try to break the parse the key but sure I need to be working with dictionary? (trying to follow you post on another thread - How do you display data from firebase? - MIT App Inventor Help - MIT App Inventor Community

Those spinner options hang off the root of the data tree, so you should set the bucket to the empty string before reading a tag.

You don't know what the previous actions might have left in the bucket, so you force it.

If you re-organise your firebase structure as I suggested, and use a label instead of textboxes, you can do this:

image

There should be no need to change the project bucket, just use the tag/s supplied from the spinner.

Is Label1 the selection of which type?
The Label2 is the display area for the bottom of the screen? If the database has more data then will fit on screen?

When I do your code and data structure - I am not getting the lower data, I am just getting {} reply

I followed your database structure
Data structure

And your blocks code

but I am not getting any data on the screen

You are calling for a tag "Salinity" (SentenceCase). You only have a tag called "salinity" (lowercase)...