Now, let me show you something very, very cool.
We're going to insert some dummy data into our database and this dummy data is in the format of Jason.
So if we head over to our real time database and yours won't look like this, yours will say, would
you like to create a database?
Go ahead and say yes.
If if you want to do this section, you don't have to do this section.
I'm just showing you that everything's working.
Go ahead and click.
Yes.
And then allow access for 30 days.
That just gets rid of the rules until we've actually developed something.
OK, if you want to do this, you will have to create your own Jason data structure to do this.
So I'm not actually going to give you the Jason for that.
This is just a demonstration.
So what I'm going to do here is import this, Jason, and before I do notice, there is nothing in our
app.
Right.
But what I'm about to do is add a whole bunch of Jason.
So here's my export, Jason.
If I double click this and I hit import and when I do that, I'm going to quickly change to the app.
There you go.
So that proves that Firebase is listening.
And when it gets that new data, it informs everyone that is making use of the data that it needs to
do something now, which in our particular case was to display that particular data.
So that's the real time demo.
And just to recap the section, because it's quite a complex set up.
First of all, you have to set up the firebase.
Most importantly, you need to add an observer to that data base reference the child of messages looks
like this.
So we have all these objects in messages.
Which are the individual messages with an ID that Firebase gives them automatically and of course,
you can see date time and text in their messages is the child that's referenced inside of this observer.
OK, so that's what we're listening to.
We're not actually listening to the whole database, although you can do that if you wish.
But I would advise that you don't.
You split your app up.
Logically speaking, once you've got that data, every time you get a new one, because we're looking
at the child added, we're going to insert a row and scroll to that row, as well as append to our messages,
data snapshot, because our table isn't listening to the live version of these messages.
So we have to do this insert manually.
Now, if you are on Android, you could tap into the room database, live observer, and that would
do all of this automatically.
So all you would need for Android is that line and potentially the scrolling line, depending on how
you want it to behave, you wouldn't need to do any magic around inserting rows, OK?
And then once we've got that, it's going to go ahead and insert the new row according to our cell phone
app.
So that is how we insert or rather how we listen to data from Firebase and how we insert adjacent file,
if you so wish to do that.