High students in this theater early on we're going to go ahead and create another Android application.
And here we just need to click on Start in your Android studio project and for the application name
just say in here app 70 and then click on next.
And here you can actually specify the minimum SDK so choose AP A16 Android 4.1.
And then click on next and he'll choose any activity next.
And here just click on finish.
So here we just need to actually connect our Android application to Firebrace.
So at the top just click on Tools and then click on firebase And here is going to actually open the
firebase assistant for us.
So here just click on real time database and then click on Save and retrieve data.
So first we need to connect our application to firebase.
So just click on button.
Just click on the spot and connect to firebase And then here you want to actually again connect our
application to apps sixty five that we actually already created in firebase.
So just take these radio about and choose an existing firebase or Google project and then select 65
and then click on Connect to firebase.
And now that our Android application is actually connected to firebase when you actually click on the
spot in real time database your app.
So just click on the spot in and then click on accept the changes.
And now that everything is ready now we can actually just go to activity on the minute example here.
So now let me actually collapsed this assistance earlier.
So here is just the selectees hello world view.
And then a person delete key on your keyboard.
So now I want to actually change this relatively out to our linear layout.
So at the bottom just click on text tab here and change this real relatively else to linearly out.
And now we need to specify the orientation of our linear left so just type in here orientation and then
choose vertical and then we can at the top here at the bottom.
So I will try to derive a list view into this linearly Ellsworthy code.
So let's scroll down here inside this palette section and inside the containers fall there so that I
actually find the containers folder.
So here is the containers folder and choose at least view here.
Just drag it here into this linearly outerwear call and select the list view and for the ID just type
in a list view and then person enter key on your keyboard.
So now I want to add the firebase database you are or you want to add that dependency to my applicable
app level project app level builder.
Great.
So we have the speed that cradle your app.
So just double click on this one here.
So just open cradle scripts and just double click and this build that great module app.
This is actually the applet will be that cradle.
So inside is the dependences block.
We can actually put our dependency here firebase database.
So let's actually open our Web browser.
So I actually entered this you are here to get hot dot com slash firebase slash firebase you are Android.
So here let's scroll down here.
As you can see it says installation.
So just copy this code here.
It says firebase a database only just copy just select it and right click on it and then click on copy.
So let's go back to android studio and here you can actually the inside is our dependencies plug.
You can paste this code at the top just click on the screen now.
So now that our project is actually synched we can use these firebase UI database.
So now let's actually go to main activity that have a file.
Let's actually double click on this tab here in order to make this area wider.
And inside this main activity class I'm going to paste in some lines of code 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 in line number 14 we have this variable which I actually declared here and I didn't initialized yet.
So as you can see the data type of this valuable is List view and the name of this variable is list
view.
And here in line number 15 we have actually a database reference.
So the name of this variable is database reference in line number 17.
We have a firebase list adapter.
So notice that you are using firebase list adapter not firebase recycle adapter here because we want
to use the list view.
We should actually use the firebase said after an inside the angle brackets we just need to pass the
data type of the model objects.
So if you want to get Buxar objects from the server.
Right.
So now let me show you the web browser here.
So let's go to firebase and here at the top I just click on go to console and you know that we actually
connected our application to 65 firebase project.
So just click on it selected and then click on database.
So now are we need to actually refresh this page so just click on to start here and then click on data
and that is going to actually show us the box that objects.
So as you can see here we have these boxes objects.
So now in this tutorial I want to let you know how we can actually delete your objects how we can delete
notes in Firebrace.
So now as you can see the bug so here is in red and this means that we don't have the Buxar class.
So now at the top just click on the View tool windows and then click on Project.
And now inside this app for lead and inside the Java folder inside this package just select this packet
and then click on file at the top new and then click on Java class and for the name just type in your
box with a capital B and then click on OK.
So now we have this box of class so let's actually create some instance variables here.
So now let me show you the web browser as you can see here we have Buxar name punch power and punch
speed.
So these are the instance variables are our box object.
So let me try the double click on the stop here in order to make this area wider.
And here I can say are private's excuse me private strange Boxer name.
And notice that the name of your valuable the name of your instance variables must be the same as the
name of your variable here.
Right.
As the name of this key box only.
So let's actually declare another ridable.
So private int punch power private punch power private int punch Spaeth semicolon.
So now let's actually create an empty constructor.
So here I can say public a boxer and then I need to put a pair of pants here and then I just need to
open and close this empty constructor.
Using these curly braces and often an incredible brace followed by a closing curly brace.
So now we need to create another constructor in order to initialize our instance variables event in
the program or developer wants to actually initialize these instance variables.
So we put this empty constructor here because it is necessary because we want to interact with the firebase
database.
So let's create another constructor.
So inside this class just right click here and then click on generate and then click on constructor
and then select all these instance variables and then click on OK.
So here we have this constructor as you can see here.
So here we are actually initializing our instance variables.
So now this actually creates some getters for these instance variables so here inside this class I can
write code here.
I can just click on generate and then I can click on get here and then here I can select all these instance
variables and then here I can click on OK.
So here we have these get help for our instance variables right.
So let's go to our main activity class and now as you can see here we have this box class yet right.
So now let's actually go into our uncreate method and here let's initialize our For example our valuable
is that we declared inside our main activity class.
So the first variable is actually assignment operator and then here I need to cast this object to this
view object find view by ID or the ID thought list view right list view semicolon.
So here I want to paste some lines of code inside this uncreate method and then I'm going to explain
to you what's going on here.
So as you can see these are the lines of code that I pasted here inline number 32 as you can see I am
truly enabling the fire of the offline capability of firebase so firebase database that get instance
that said persistence enabled.
So you are already familiar with this code and in line number 44.
I am actually creating an instance of type or firebase so firebase a database a database assignment
operator firebase database that get instance right and an inline number 55.
I am initializing this database reference so database reference assignment operator database that gets
reference right.
And here again because we want to enable the the offline capability of firebase we need to put this
code here database for friends that keep seeing the truth.
So now so now let me show you the web browser here.
As you can see here I have these boxes objects here right for example Avon a zero a 1 and 2 and these
other objects.
Now you may want to actually delete all these objects right.
So let's go to Andrew would you and I can say database reference.
Right.
They have a different Stut said excuse me remove value set semi-colon.
So in this way we actually we have a reference to our north right.
This is our north.
This is our database instance.
And then I say database reference that remove value is going to actually move all these children of
this database instance it's going to remove the values of this database instance.
So here we are saying database inference that to remove value.
So it's actually not our project now and then click here choose up connected device of our device or
maybe a real device and then click on OK.
So now let me show you that browser here and now we can actually delete all these objects.
So let's make a little bit here.
So now as you can see here all these data now are deleted.
Right.
All the children of this north of this instance are now deleted.
Why.
Because we put this code here a database of friends that remove value.
So by using this code you can actually move your your children in firebase right your database of children
your notes in firebase.
So now I'm going to actually just comment out this line of got here and now let me show you the web
browser as you can see here.
We have no children here right.
This note doesn't have any children.
So now I want to I want you to send some children some box of objects to the server.
So in order to do that I can't just create a for loop and here I can say it.
All right.
Assignment operator zero.
So this is going to be the initial value and now I need to actually specify the condition in which determines
how many times this fall is going to be executed.
So this fall of here is going to be executed until the value of this is less than for example for the
right semicolon.
And then here I can say that this Fall of year after each execution of this Fall of the value of this
idea is going to be incremented by 1 and then I can just open and close this for loop by using these
curly braces and opening curly brace for the closing curly brace and then here I can literally create
a boxer object.
So Boxer Boxer assignment operator new boxer.
So here I am actually creating a new boxer instance.
And here for the name I can say for example a.
Right.
Plus all the write as you can see for the name of our books that I am saying that a and for example
for the first time that this fall here is going to be executed this initial value is actually playing
the role of it actually the role of an index.
Right.
And here we are seeing a plus one for the first time that this year is going to be executed.
The value of this is zero.
So it's going I actually sent a box that objectivity a zero to the server and for the second time that
this is going to be executed.
Now the value of this is actually incremented by one.
So now the value of this is actually D1 right.
Right.
So and then it's going to send a box that object to the server with the Buxar name of a one and so on.
Right.
So this is our first argument which is actually going to specify the name of our boxer and then we need
to specify the punch power of the punch power is for example one thousandth and the punch spit is 2000
semicolon.
So unable to actually send this back this box that object to the server.
So here I can say database reference but child database reference.
Right.
So here I want to create a unique IDs for each box set objects so they have a reference that push dot
get key.
So when I say that push is going to actually create that specific unique ID for my specific box that
objects.
So they have a fence that push that gate key that sets value.
So now I can actually send my box of objects to those IDs.
So set value Buxar semicolon.
So now we have this for loop right.
So it's going to actually create a box of objects here and it's going to actually send those boxes objects
to the server.
So let's wrap our project now.
Now let me show you the web browser and here it is our Actually emulator.
So now you can see that the Buxar objects are actually sent to the server.
Right.
So we have 40 bucks that objects to the box a name is a zero.
The first box that update is a one on the end as you can see here a 29.
So because it actually starts with a zero it ends with 8:29 right.
So let's go to our Android studio here and here I'm going to actually pasting some lines of code.
So here inside this uncreate Smurfette I need to actually initialize our firebase least adapter.
So as you can see here in line number 18 inside this main activity class we actually declared our valuable
fire baseless adapter at inside our uncreate method.
We need to initialize this value.
So before the end in curly braces of this uncreate Mefford and insight this uncreate method I can just
typing firebase list adapter assignment operator.
And then here I can't just put the new keyboard and here I can hold the shift key on my keyboard and
then press on the letter F G on my keyboard.
So now I can actually select this option.
So now as you can see here the autocomplete feature of Android studio is actually helping me to choose
this option for your baseless adapter.
So just select it and then press an interview on your keyboard.
So now after the end in curly brace of this I actually firebase this adapter here only to put a semicolon
here.
And as you can see here we have this up a pair of practices.
And if we actually hover over this error we need to actually it says that we need to provide some arguments.
So the first argument is actually the activity the context.
Right.
So the first argument is the context which is going to be the main activity to this right.
And the second argument is going to be the model class.
So the model class is actually a box in the class because if you want to actually get the box set objects
from December you also sent this box that objects to the set.
Right.
So if you want to get these objects from the center and for the first argument as you can see here of
I need to specify the layout of our items of item views and for the forth argument or final argument
we need to specify the database reference.
So first of all let's actually just put the first argument here.
So the first argument is actually an activity that this comma.
Now let me actually create a newline character here a new line.
And for the second argument I need to specify the model class of boxers that class come.
And for the first argument I need to specify the model lay out light of item or item views.
So here I can say Android dot Android dot or dot lay out dot see me here are the mistake and we have
a typo Android right Android that are that lay out.
That's a two line list item.
So if you have a simple list item one and we have to line list items which was this one instead and
then person it on your keyboard.
And for the final argument we need to actually pass the database reference here.
So now we have no errors yet.
Right.
And here we have this populate new method.
So let's go inside the populate view method now and here.
First of all let me tell you that we have this for for loop here right.
And the job of this for loop is actually to create Buxar objects fretty box that objects and to send
these objects to the set up.
And now let me show you the server.
Let me show you the web browser as you can see here.
So here we have 40 bucks that objects right.
So whenever have run an Android application it's going to execute this for loop here for us.
So it's going to actually send a 50 bucks that object through a server error free.
Every time we actually do it on our Android application.
So now I don't want to create a 50 box of objects every time that we have to run our Android application.
So let's actually comment out this follow up here.
So now let's actually go inside these populate view.
So let's look at this to populate buma if we have this method method and this Linforth have has a free
arguments.
The first argument is actually offtake view and the name of this argument is weak.
So this should change the name of these arguments to view.
And the second argument is actually the model which is of a boxer and the first argument is going to
actually specify the position of each item inside our list view.
So first of all I'm going to actually get the data from the server and I want to put that Putin's to
insight Arliss view.
So as you can see here our layout is actually two line list item right.
So now here I can say.
So now let's actually put a pair of parenthesis here.
And if you look at this lay out it says to line list idea.
So this means that we have two text views inside are each item inside our item view.
So first we have a pair of practices and inside is Apprentice's we want to actually put another pair
of prentices and here inside the inner Apprentice's.
I want to say text view because I want to actually cast this object to a text object right.
And here I can't say view that find view by ID.
Android dots are dot ID dot takes one.
So this takes one is going to actually keep the first text so here the first line.
Right we have to line.
So this takes what is going to actually give us the first line the first text view.
And here I can say that said text.
So here I can actually get the name of a boxer model that gets Buxar name right.
And we have another line.
Right.
So here again I put up her Apprentice's and then another practice's inside this prentices and inside
the inner prentices I can just see a text view.
And here I can see a view that fine view by ID or thought Id is me Android.
Dots are dots.
Id dot takes two text two because we have to lie.
Right.
So that takes two that said text model and now I want to get the punch power and upon speed so modern
that gets up punch power.
So a plus.
So let me create a new line model that gets punch power plus and then life with two double calls.
And then I actually create a new line character plus modern that gets punch speed.
So in this way we can actually output the punch power and up and the punch speed here for takes two
and it takes one is going to actually hold the value of the box certainly.
Right so now let's run our application.
And now let me show you the web browser and let me show you the emulator here.
So now as you can see here we cannot see that data here inside our lease view.
So let's go back to and would suit you and this means that we have actually an error and the error relates
to adapt the adapter.
And we forgot to actually set the file baseless adapter to our list view.
So here I can say at least view or so after the end in embrace of our firebase list adapter and inside
this uncreate method I can see list view that set adapter and the adapter is firebase list adapter.
So now let's run that application again.
Let me show you the web browser and the emulator.
So now as you can see we can see these data here right inside Arliss view we have for example this item
a want a zero as you can see and the boxes a punch.
Power is 1000.
And the punch spit is 2000.
And we can see all these other box objects that we get from the set.
Right.
So now let's go back to android studio.
And here I want to do something else here.
Whenever the user clicks on one of these items here inside Ali's view I want that specific item that
is actually clicked or you want that item to be deleted from our database.
And from our list view.
So first we need to actually make our views as you can see here we have this nice view.
And each item has a view right.
So I've only to actually make these views actually a listener to the clicks of the user.
So inside our populate human effort as you can see here we get this argument which is of the view from
this populate human right.
So now inside these populate populate if you make it I can't say view I am referring to this argument
that said unclick listener knew.
And here I can't just hold the shift key on my keyboard and that person that person the leader Vicci
on my keyboard and he had the autocomplete feature of Android studio is going to help you to choose
this option.
And then precedented on your keyboard.
So now we have this unclick listener here and we have this uncle Mefford.
So inside his uncle's effort to create first a toast does make text.
So the first argument I need to pass the context make me an activity that this comma.
And for the sake of argument I can say deleted deleted item at position the little item or position
Kallen plus So as you can see from this populate Fuma we get the position right this argument so we
can actually have access to the position of each item inside our lease view plus position.
Right.
And come on.
And for the first argument I need to specify the length of our toaster so short that and then I need
to call them if it show an object on our host object.
Sure.
So we have this host object here.
So now let me actually create a new line so that you can see this post here.
And now I want to put the logic in order to actually delete each item whenever the user clicks on each
item view.
Right.
So first of all we need to have a reference to are actually to our specific ideas to our specific object.
So as you can see here we need to have a reference for this actually to this object in order to delete
it.
So now let's actually go to our Android studio here and here inside this Anklage Smurfette.
First we need to actually create our reference right.
And the data type of this reference is actually database reference the name of this variable is actually
my ref assignment operator.
And here I can say firebase list adapter does get ref.
And here we need to pass the position.
So as you can see here we get the position from this populate view.
Right.
So inside the apprentice's I can't just pass this position in order to get that specific ID inside that
specific position.
Right.
And here I can just as you can see we have this local variable which is of type database reference.
Inside is an agreement if it and the name of this variable is made f and here I can say myself that
remove value semi-colon.
So in this way we can actually have the we can have the access to our specific idea and to a specific
object inside a database and we can actually delete it.
Right.
And we can also delete that specific object inside our list view.
So first let's actually do our project and now I can actually show you how we can delete all Buxar objects
inside our database and our view.
So let me show you the web browser and here it is our emulator right.
So now as you can see this is our app 70 right and this is our boxed object and the box and it is a
zero.
And this is our box that object.
So now I want to delete this item I want to delete the sparks that object here.
So I just need to click on the item here and now it's a delete or deleted item at position 0 and the
object is also deleted here.
So we have this box name a word.
Right.
So now let me click on this item view here.
And again this item is deleted here.
I can also delete this too.
So now let me open this idea here.
As you can see it's as a two so I can just click on this item and now it is actually deleted.
So I think that's enough for this Tauriel.
And I actually got you lots of important concepts in this lesson.
So if you have any questions please pass the discussion in the course and then I do my best to answer
all of your questions.
Thank you very much for watching and I'll see you in the next year to Audiard.