So now let's actually go to our Android studio and here let me actually double click on this tab here
in order to make this area wider here.
So now I want to actually get the value of this key.
Let's go to our web browser and here we have the school here right.
So let's change this value here to for example.
This is a value to and here as you can see I changed the value of this key.
Right.
So now I want to get the value of this key.
So let's go back to an android studio and now here.
After the end in apprentices of this the listener here at value listener for this key as you can see
I want to actually create an orderly center for another key.
Right.
So now here still I am actually inside this uncle listen at here Uncle unclick my fate here as you can
see.
And now this block of code here is actually related to Diski.
I created actually an add value listener for this key right.
So now I want to actually create another add value listener for another key.
So after the end in practice here of this listener as you can see so just typing firebase database firebase
database does get the reference.
And now I need to specify the reference so inside the double quotes.
Let's actually go back to our web browser here.
As you can see we have this here.
So just select this key here as you can see this is our key right here you can enter the cockpit is
key.
So just highlighted here and then just right click on it and then click on copy.
So now that I actually copy this key here let's actually just click on this link here.
In order to see the whole database here.
So let's go back to Andrew with you.
And now I can actually paste that key here.
Right.
And here I can say that as you can see here adds value in it.
So now let me actually create a new line here and here I can say that add value event listener.
Right person until you on your keyboard and then just put the new key word here and then hold the shift
key on your keyboard.
And then just put it like capitalized to the letter here and now you can select this option and in person
it'll be on your keyboard.
And now the autocomplete feature on Android studio is going to put these lines of code here for us.
And then as you can see here we have this error here and we need to put a semi-colon after the end in
Prentice's here.
Right.
And now we have two methods.
The first one is on data change and the second one is uncancel.
Right.
So I told you that this method on data change is going to be called of when ever we actually click on
the spot in get data from server PTEN get data from server and it's going to actually also be called
when ever we change the date of that key.
So for example here as you can see we have this key here right and now if I show you the emulator and
let's actually click on the spot and get data from server as you can see we got this data.
This is a value right.
So now this value is actually the value of this and to the cheat.
So let's actually change this value to another value.
Let's see what happens.
And here I can say for example some value right and then press on intel on your keyboard.
And now as you can see here I changed the value of this key right.
So now this value is also changed inside our emulator some value.
So that on the top change method is actually called an error that you actually change the value of your
key.
Right.
So let's actually change it to another value for example.
We can actually just type in here my value enter and now it says my value as you can see here.
So now let's go back to android studio.
So here I created a listener for this key right for this key.
As you can see here.
So now inside the update or change method as you can see I can just type in here.
Streambed
And here again value assignment operator and here in order to get the data as you can see we have this
argument data snapshot.
So this argument actually holds the value of this key.
So here I can see data snapshot right data snapshot that gets value semi-colon and here I need to specify
the data type.
So inside the practice's I can just say strange thoughts.
Class right now I can just print that value here.
So here let's actually create a log.
So log.
That's right.
And first of all I need to specify that right.
So just put two double quotes here and then just type in here t a g tank comma and then here I can't
put the value here value and then semicolon.
So now let's actually just run our project and now let me actually just show you the web browser and
then let me show you the emulator here.
So now I want to click on the spot and get data from server.
First of all we have this value here right.
But the value of this second key as you can see here is going to be logged here to the console.
So let me show you the Android studio and here at the bottom click on Android monitor and here as you
can see we have this search here the search bar just typing here THG as you can see.
And now as you can see here in the console we have this value.
This is a value to.
Right.
So this is the value of this key.
So here I can just delete this value.
And here I can say this is my own value right.
And that person enter key on your keyboard.
And now if I actually go to Android Studio inside the lug you can see this value.
This is my own value.
So if something in order to actually clear the logjam here you just need to click on the spot in here
right to left right.
Clear like that.
And now as you can see here we have nothing here.
So now let's actually change this value again.
So here I can for example say number 100.
And that person the key on your keyboard.
And now if I go to the live chat here let's see what happens.
So as you can see here nothing happened.
Why.
Because of he said that the value that we are going to get from these key is going to be us think value.
Right.
So now let's see how we can actually get an integer value from the database.
So as you can see here let me show you the web browser as you can see if you have here an integer value
right.
So now I want to get an integer value not and think value right.
So not our string value.
So let's go back to our Android studio and here I can actually create a variable so it and the name
of my variable.
As you can see I am in status on data change method here right.
Inside is Uncle I value listener here for this key so he can say it and the name of my else can be in
value right.
Assignment operator.
And then here I can refer to the name of this data or snapshot here.
This argument does get value.
And inside Apprentice's because this is actually an integer value that you want to get inside Apprentice's
I need to say integer class.
And then at the end of my code at the end of my statement I need to put a semicolon.
And here I can say log.
That's why I'm here for the first argument.
I need to specify the tag which is of type streams.
So tired come up and for the second value which is actually an integer value I need to refer to the
name of my variable into value plus two double quotes because the second value is going to be must be
actually of type string.
Here we need to convert these Vadi disvalue integer into value twice think value so that we can actually
put it here and now because we want to actually get an integer value from the database we need to comment
out these two lines of code here because we don't want to get a string value.
You want to get an integer value right.
So now here at the bottom it's actually clear the law can't.
Let's actually run our project now.
And now let me show you the web browser and the emulator and here as you can see I just click on the
spot and get data from server.
And as you can see here this is the first value for this key right.
And the value of the second key is going to be locked to the console.
So let's go back to what I understood you in the in the Luczak here you can see this value number 100.
So now instead of outputting this value to the log it's actually just put it to the user interface.
So here I can see the value that set text and here I can just refer to the name of this value and the
value of this variable into value is going to be replaced by the previous value which is actually the
disvalue right the value of this thing value.
But because we are calling this method that takes on this takes the value again here.
So here I can say that it's value.
But because this is actually as an integer value and we need to actually provide a string value for
this method it takes that actually converted to our actually think value by concatenating this value
to an empty string value.
So let's actually again run our project and now let me actually opened a web browser.
And here this is our emulator.
So now let's actually click on the spot and get data from server.
And now we have this value 100 right as you can see.
So now let's actually get the value of this key.
As you can see this is actually a category right.
Let's get the value of this up key child here.
So let's go back to our Android studio.
Again we need to actually create a listener.
So let's see how we can do that.