So here first of all let's actually a create a variable which is of types three in here inside our class.
So first let's specify the access modifier which is actually private.
And now I need to specify the Data Type of my variable which is string and the name of my variable is
all it takes the received data semicolon.
Right.
Now as you can see if this variable is going to actually hold the all the value of our Takes view which
is this one takes the received data.
So now let's actually scroll down here and let's go inside this and later change my faith.
Now I'm going to paste some lines of code here and then I'm going to explain to you what's going on
here.
Exactly.
So as you can see here.
So as you can see here these are the lines of code that I pasted here.
Inside this on data change method.
So first of all we have a for loop.
Right.
And here you are actually iterating over the values of this state snapshot.
You're either reading over the children of this data or snapshot.
So first as you can see we are calling this add value event listener and this database reference.
So let's scroll to the top here and let's see this valuable database reference.
What is the value of this reference as you can see we are referring to the database reference right
database that gets reference.
So this means that we're are actually referring to let me try to show you the web browser.
We are actually to this instance to this node right when we call database that gets reference is going
to actually give me this note.
So now we provided some children for this note.
As you can see here this one is the highlight of this note and this one as you can see is actually the
height of this note.
This one is the height of this note.
And this one is also the child of this note.
So here we are referring to this note.
Right.
And you are assigning that reference to this database reference variable.
So let me scroll down here.
And here I am actually are either 18 or at the children of this reference data or snapshot.
So when I say database reference that value even listener I am actually creating a listener for this
note.
So what ever whatever happens to the children of this note or two did to this not directly.
Are going to be notified.
Right this update or change if it is going to be called what happens to this node or to the children
of this note.
Right.
And now let's get into insights on that or change it.
But we are we want to as you can see we have children right.
This note has children and we actually created this for loop in order to either aid over the children
of that node.
So I say 48 hours snapshot data snapshot Boxer object.
So as you can see here we have actually a valuable right data snapshot box that object.
So as you can see because we are receiving the data up from the server as the value of type data snapshot
we are actually creating a valuable type data status snapshot which.
Its name is box that object.
And we want to iterate over the children of this data or snapshot that we actually receive from the
Smurfette right.
We receive data as a data snapshot.
Right.
So this data snapshot actually holds this note right.
This data snapshot here holds this node and I am actually getting the children of this note.
So in this way we can actually access the children of this note and we can actually either take over
these notes over these children and we can actually access the objects or box that objects as you can
see here.
So each of these IDs actually has Buxar object as you can see here.
So as you can see this for loop here is going to be executed for each boxer object that we have inside
our server.
So as you can see for example this for loop here is going to be executed for each child.
So let me show you the web browser as you can see this is the child.
Right this is one of these tights.
This is an adult child.
This is another child and this is another child.
So for the first time that this is going to be executed the value of this box that object is going to
actually hold this box that object variable is going to actually hold this child.
Right.
This one.
And now let's actually to go inside the curly braces of this for a loop and let's see what's going on
here.
First of all you're actually getting the boxer object.
So you are getting the boxer object from this child.
Right.
So this actually holds this box that object.
Let me show you this again.
This I.D. here actually holds this box object which its name is a it's punch power it's one hundred
and each and it's punch.
Speed is 200.
So now in line number 72 I am getting the box object.
So Boxer Boxer assignment operator and here I am referring to the sparks that object from this fall.
As you can see here inside the apprentice's all told you that this is going to be executed for each
child that we have here inside our server.
Right.
That we have for this note.
So for the first time that this fall here is going to be executed the first child is this one.
And in this way we can actually get the box objects or box it up take that good value boxer that class.
So here are we.
I should change the spots that object child.
Let's actually change this one also to child and in this way it makes more sense.
So here you can see that we're actually either over the children of the state or a snapshot which is
this one.
This is the latest snapshot right because it holds the reference to this note.
So first we are actually getting the box set up to act like creating a variable of type Boxer and its
name is Buxar assignment operator.
And here I am referring to this child.
Right.
That gets value boxes that class.
So this idea here is actually the height of this note.
Right.
And when I say child so I am referring to this ID that gets value.
The value is actually the sparks that object.
Right.
Box it and its type is box at that class.
So we must specify the type.
So inside the prentices I just say boxes that class.
And here we have an if statement.
And here I am saying that if all the received data.
So here I am referring to is sitting valuable that we created here in line number 28.
So so here I am saying that if the value of this variable is actually null then instead of printing
a null instead of actually displaying the value not to the user just that display an empty value swipe
instead of double quotes.
Or just put a space right on MTV.
So all takes the risk.
If the assignment operator an empty string value right and now after this if statements look at these
lines of code here I am saying that TXI received data.
So here I am referring to this text view that that we actually declare here inside our class and to
be initialized.
This takes you here inside our uncreate Smurfette.
So here I am saying that TXU received data that said text old to receive data.
So first I want to actually print the old value of party activity data.
I want to actually display this value first plus And then I am referring to the sponsored object that
gets box surname right.
Buxar that get Buxar name first.
I want to display this value plus an inside double quotes we have a dash plus.
And then I want to print this value box that gets punch power plus dash plus boxer that get punch speed
plus.
And here we have this backward slash.
And so this is going to actually create a new life character after printing the values of our boxer
objects.
And finally as you can see here we are actually assigning the value of RTX the received data here that
takes that whispering to are all ATX to receive data.
So in this way this variable here is going to actually hold the old values of RTX to receive data as
a string value.
And we can actually display all of those values to the user.
So now let me actually run our project and then it will make more sense.
So now as you can see here our application is actually running on this emulator and now you can see
that we received the data from the server.
So the first Buxar is name the name of the first Buxar is a.
And the punch power is 100.
And the punch spit is to hunt that so you can see these values here.
The second box is B 10 20 C 490 and D 4900.
So these are the Buxar objects that we are receiving from the server.
So let's actually create some more Puckster optics so here I can say a b c d e 20 free 12.
And here as you can see we have again these values a 100 dash 20 write the 10 20 C 490 and the 14:19.
So when ever I actually click on the spot in the all the values of our text you are going to be also
displayed.
Right.
And then we have also the new value which is this one.
And if it is a scroll down here you can see this here.
And as you can see it because you actually created a scroll you can actually scroll here.
So let's actually create some more values here.
So here I can say for example a B C D E F and the box a power punch power is for example 90 depan speed
is 2000.
And if I can send data to several here and again you can see that these values are again displayed.
They have a B C D E and F right.
So these values are the old values of art.
It takes a view and we have also the value of the newest object that we actually sent to the server.
So that's why.
Let me introduce you to the Android studio that's actually created this valuable all the exclusive data
in order to hold the the old value of RTX the receive data.
So if I actually create for example someone objects G and if I click on this button for example it may
create some objects which send that observer they send data to a server.
And now as you can see we have all these objects here.
Right.
And we have these objects A B C D E F G H k.
You can see that I actually put these values here and we have also the old values that are actually
printed here.
Right.
So here in this tutorial I wanted to show you that how you can actually either aid over the children
of your note.
So let me show you the web browser.
So here as you can see let me scroll to the top as he has it is our notes right.
And we are referring to this note not a specific child in the previous tutorials.
I actually told you about up just referring to one specific child in order to get the values of that
specific child.
But in this the story or I am showing you obey in order to iterate over the children of your note and
get the values of all these notes right and get the values of all these children.
So now let me show you another important point.
So now let me show you the emulator.
And as you can see here you can see these values here and you can see that the older values are actually
displayed here multiple times.
Maybe you don't want this to happen right.
And here in order to solve this problem before this for loop here I can just refer to the name of this
valuable old Teac the received data assignment operator.
And then I can assign an empty string value to this variable.
So let's run our project.
And now here I'm going to actually explain to you what's going on here.
Exactly let's actually see our application here and now it can actually display these values here that
are going to be received from the server.
So now you can see that we have only this a here b c d e f g h k and we have these are all other values.
Let's actually open our web browser.
Let me create another box and object.
So here for example I can say Buxar a box or a.
And the punch power is for example 5000.
And the punch speed is 5000.
Right.
Let's actually click on the spot and send data server.
And here as you can see we have this object right.
But you can see that the previous values the old values are not printed are not actually displayed here
again.
Right.
So you can see that we have also we have just this value and if we actually print P for example it may
actually disappear.
This virtual keyboard for example box.
And if I click on the spot and send data at the server.
Now you can see this box here.
Right.
Let me actually change this to boxers see if I click on this button.
Now we have only the sponsors see why.
Let me show you the Android studio.
So for example you know that is an update or change if it is going to be called when ever the user changes
the date of an event that they are inside.
Our server is after the change.
So now you can see that first of all we are actually assigning the value zero to this all takes the
received data and we have this for loop here.
So this follow up here is going to be executed for each child that we have inside our notes.
So now let me show you the web browser so you can see that we have this note and these are the children
of this note.
Right.
We have multiple children.
We have lots of children here and now or you can see that we are getting the box that object from these
children as you can see here for example.
This is the first child and this is the box of object.
Right.
And here you are actually creating this if statement.
So I told you about this if statement here and you're actually getting the value of that Buxar right.
For example box name a 100 200.
So now let me show you the emulator.
So this these are the values.
These are the values of 100 200.
And here in this line of code you are assigning the value of these Teac still receive data to this all
the receive data body.
And so in this way after this follow up finishes executing these lines of code we have all these values
here.
Right.
So in this way you can see that we have these values and if we actually create another box that object
for example box of the then in that way again it's going to actually send this data to the server and
we can actually get.
Again it's going to execute this for loop and it's going to actually display these values here.
But you can see that when this data change if it here is going to be executed first it's going to actually
empty the value of this valuable all text receive data and then it's going to actually execute this
for a loop.
And that's why you can see that these values are here and these values are not repeated.
We can only see this here once B C and all the all the other values.
So hopefully that makes sense and I think that's enough for this theater.
So if you have any questions about the concepts that are hard to you in this tutorial please post the
discussion in the course and then I'll do my best to answer all of your questions.
Thank you very much for watching and I'll see you in the next year.
Tanyard.