So now let's actually scroll to the top here and here inside our main activity class.
I'm going to actually declare and other three invaluable.
So here just type in strange and here the name of this string value but is a computer or you can say
unique computer ID.
OK.
You need computer 80.
So as you can see inside our class main activity class we created the bell which is of pipes.
And the name of this variable is unique computer ID.
So now let's actually scroll down here.
So let's actually go after the Indian curly brace of the Smurfette of this uncreate method.
And inside this class.
So as you can see here this is the ending curly brace of this class and here this is the ending calibers
of this uncreate method.
So before the end of this class and inside this class inside the curly braces of this class I'm going
to actually paste in some lines of code here and then I'm going to explain to you what's going on here.
So as you can see here these are the lines of code that I pasted here.
So we have a method and the access modifier of the Smurfette is private.
The return type of this method is void.
So as you can see here when I say that the axis modifier of this method is private I mean that this
method is only accessible inside this class.
So you already know about access modifiers in Java.
And here we say that the return type of the term type of this method is void and dismissed.
This means that this method is going to return.
Nothing is going to just do something right.
It's not going to return anything.
OK.
And then the name of this method is produce a new computer and put it in the database.
So the job of this method is to create a new computer object and to put it into the database in the
server right on the server.
So as you can see here this method actually accepts some arguments.
The first argument as you can see here is of type string and the name of this argument is computer name.
The second argument of this method is actually the computer power which is of type integer.
The first argument of this method is actually computer speed which is again of type integer.
The fourth argument of this method is actually computer RAM which is of integer.
And here we have computer screen which is of type string.
And we have computer keyboard which is a unit of papes trained and we have computer CPQ which is after
high street.
So now let's actually go inside the curly braces off the Smurfette And let's see what's going on here
inside the Smurfit as you can see we have this statement and this statement here is saying that text
U-2s so the text utility is actually a class in Java that we are going to use in order to actually do
something with our texts.
So the utility class is going to actually give us some methods in order to actually do something in
order to check whether for example this unique computer ID variable is empty or not.
So we can use this class in order to check this here in order to check that with this unique computer
ID variable which we created inside this class inside me and like if the glass is empty or not.
So now let me scroll to the top here.
As you can see inside this class we created we actually declared this variable which is of types 3 in
unique computer ID and we didn't initialize it yet.
Right.
And now as you can see here inside the Smurfette inside this method you use on your computer and put
it in the database.
Is it saying that it takes you to use that is empty.
So this class takes you to is going to check by this.
But by using this method it's going to check that whether this unique computer ID is valuable is empty
or not.
Right.
And if this expression evaluates to TRUE this means that if the value of this unique computer ID valuable
is actually empty right then it's going to go inside the curly braces of this method and it's going
to execute this line of what here is going to actually assign a value to this unique computer ID so
unique computer ID assignment operator and we are actually referencing our database so you already know
that this database reference valuable is actually holding a reference to the computers category into
the database.
Right.
So you need computer ID assignment operator database or friends that push.
So you know that when I call to push my faith here on our reference it's going to actually create a
unique ID.
Right.
So when you call the push method on your reference it's going to create a unique key or unique a unique
ID for or actually reference.
Here we are calling this method get ciii an undisputed truth can actually get that value that that unique
random ID is going to get that key and it's going to assign that key to this unique computer ID so that
she is going to be off the street.
Right.
Which is actually an object so we can assign it to this unique computer ID which is off the street.
Right.
And now as you can see here we have these lines of code here in line number one hundred and sixty two.
We have created an object of type computer class.
So if we actually go inside this computer class here you can see that we have these instance variables
computer name computer power computer speed computer ram computer screen computer keyboard and computer
CPQ.
These are the instant Swabia bells of this computer.
Right.
And we have these empty constructor which we needed which it is important that we actually put this
into a constructor here.
And we also have this constructor that is going to initialize our instance variables.
Right.
So you know about these kinds of constructors in Java and as you can see here we have these methods
or these getters in order to actually get the values of our instance variables.
So for example computers will compute return computer CPQ.
Right.
So inside is main activity that Java class as you can see here here here inline number of 162.
We created an object OFF-SIDE computer assignment operator new computer.
So as you can see here we are actually creating a new instance of type computer class.
And here we are going to assign that instance to this computer invaluable right.
This is actually a about right.
And here after the assignment operator here you are creating an instance of type computer class and
then we can actually be assigned this instance to this variable.
So whenever that you want to actually ferde to this instance I can just refer to this name here to the
name of this value.
So again computer computer assignment operator new computer.
And here we are using that constructor that is going to initialize our instance variables.
So as you can see here this method you use in your computer and put it in the database method.
This method has some arguments right.
So by using these arguments I can initialize this instance.
So for the first argument I passed this computer name which is of types 3 and for the second argument
I passed the computer power for the first argument.
I passed the computer speed for the forth argument I passed the computer RAM and here I passed the computer
screen computer keyboard and computer CPQ.
So you have created an instance of type computer class by using these arguments of this method.
Right.
So then that I call this method and then I actually passed these values to this method is going to actually
create a new instance of type computer class for us.
Right.
And here in line number one hundred sixty four as you can see I am referring to this database reference.
Right.
So this database reference has already a reference to the computers category.
So if I actually scroll to the top here and go inside these uncreate Smurfit as you can see in line
number 66 as you can see here we are actually creating a reference to the computers category.
So that's why I said that these these databases are friends is what is holding a reference to these
computers category.
So let's scroll down here.
So now I say database or France that child.
And here I specifying the key right the name of this child the key unique computer ID as you can see
here.
So the key is this one right Junichi computer ID dot sits value.
Computer.
Right.
So when I say sit around your computer as you can see here this is actually an object of type computer
right.
So this unique computer idea is going to be actually up.
Category.
Right.
So we have actually a reference to the computers category and here as you can see here in line number
one hundred and fifty eight we are creating a unique ID a unique ID that is randomly created and it
is not going to be the same as any other ideas that are going to be created by the firebase.
So when I say database reference that push is going to actually create a unique ID for me right dot
get key is going to actually get that ID and is going to sign that ID to this unique computer ID which
is of type string.
So now this unique computer Id actually holds that unique ID that is created by the firebase then I
call this push method is going to create that ID.
And here we are getting that.
And we are assigning that key to this unique computer ID in low number of 164 as you can see here I
am saying that database reference.
So this database reference is actually holding our reference to the computers category right.
And here I am specifying the child of that can computers Kathakali.
So the child of that can computers category is going to be unique computer ID right.
So now we have our computers theoretically and the child of that computers category has this.
She has this unique computer ID.
And here we are saying sets value computer.
So this means that is going to actually again treat this Junichi computer ID as a category because we
are passing this object here.
Right.
So now let me actually to go inside the computer class as you can see here we have this instance variables
right.
For example computer name computer power computer speed computer ram computer screen computer keyboard
and computer CPQ.
So when I pass an object to our category here as you can see when I pass an object to our category for
example this one unit computer ID is going to actually put that object with those names and values.
Write is going to for example create a name.
For example the name is computer name and the value and the value is going to be the value that we passed
through this method to this method here.
As you can see so now when we run a project I'll talk more about that later.
And it will make sense but for now just know that we are saying that it is an offense that child the
child is unique computer ID.
And it's going to actually treat this unique computer ID as a category.
Why.
Because we are sitting on the computer object to this unique computer ID that object has keys and names.
So now when I run my project you will see how this works.
And here as you can see in line number of one hundred and sixty six we are calling and other them if
it change the text of send or update button.
According to the situation.
So now let me show you the emulator here.
As you can see let me just make this virtual keyboard disappear.
So as you can see here we have this edit text and the user is supposed to actually enter some values
here and when the user just click on this send button here it can actually send this data to the set
right.
Right.
But after that I want to actually allow the user to update those data are right.
And then when I want to actually update those data I can actually hear change the takes of this button
to update data.
So that's why I actually created this method here.
I actually put this fit but we haven't still created this method.
And that's why you can see that this method is actually in red.
Change the text of sent or update button.
According to the situation.
So after the end in calibrates of the Smurfette Let's actually create the Smurfit here.
Here I can say private and here I can say void and then I can actually first with the name of the Smurfette
change the takes of send or update Potten according to the situation.
And then I put a pair of parenthesis here and then I open and close this method by using these curly
braces.
And now as you can see here the error is gone right.