Firebase CURD operations Android | Firebase Add Update Delete Search and Display in Android

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome to my youtube channel in this video i'm going to show you a quick overview of an app with the help of that app we are going to perform card operation on the firebase database okay so initially in the first video i will show you how to actually put the data in the firebase real-time database and here you can see this i have set some data and how to set the id and also i will show you how to set the rules so that we can access these data in our application after that i'm going to show you how to actually fetch this data into my app so my app is f-based so i'm going to open it and here it's open and here you can see this initially the data is gurima and it's therma is visible over here the course is baked and and karima at the gmail.com the email id and here you can see this every data is being fetched we have total of six and one two three that is total of nine records and if we count we have one two three four five six seven eight nine total of nine and i will also show you how to actually set this image view that will be the circular image view inside this one here you can see this every image is circular okay and after the following this we are going to add a search box over here with the help of the search box we can actually fetch the detail of any particular user with the help of rohit if i type r only r then the name starting with r will be visible over here and i'm also going to show you how to actually search by name or by course or by email id you can change it according to your need after that i will show you how to perform the edit and delete operation when i click on edit it will actually ask me to edit the record so anamika and i can change the name to namika kumari and something like this if i update and here you can see this stuff anamika kumari is updated if i move back to the firebase database and search for this anamika let me search for this and here you can see this dynamica kumar is updated in our firebase real-time database so i'm going to show you how exactly this work and how to add this update pop-up over here now move back and change it to the previous one and finally i'm also going to show you here you can see this is added and i'm also going to show you how to perform this delete operation when i click on delete delete deleted data cannot be undo and here we have two option that is cancel and delete if i click on delete the data will be related and if i click on cancel the data will be still in the same way as it is and in the last video i'm going to show you how to actually add this one that is a floating accent button to add the data click on plus and it will open up activity like this and here you can add a new data like abc course will be btech and abc at the rate gmail.com and inside this one you have to put any image from the google so i'm going to search for an image maybe okay so i'm going to use this so copy this one and copy the image link and move back over here the app and just long press it and paste it like this and save now the data's inserted successfully and every field is cleared and now i'm also going to show you how to clear this field when i click on the save button and after saving the data one toast is being shown over here that data is safe successful if there is any error the toast will be different that error while inserting the data if i click on back and if i check for abc now the new data must be added here you can see this abc and the images what we have copied the link and i'm going to delete this if i click on delete data delete cannot window if i click on cancel cancelled is visible in the toast and if i click on delete and the abc is later now if i try to search for abc nothing is visible over here if i try to search for a anamika yeah this one is visible if i search for tom yeah tom is also visible so i'm going to show you how to perform these all operation in detail so just stay tuned subscribe and share with your friends and keep watching hello everyone welcome to my youtube channel from this video onwards i'm going to make a video series on card operation on real-time database firebase so before performing the code operation first we need a database with some data so that we can perform operations on that data so in this video i'm going to show you how to actually create the database and how to set or store some data into that database and how to set rules so that we can actually access and update the data in our real time database so here you can see this this is the data which i have previously created but in this video i'm going to start from the scratch so go to the google and here first thing what you have to do is you have to sign in with any email id you have so i have signed in after that what i have to do is i have to search for firebase search for this and here you can see this the first one is firebase or the second one you can click on any just click select one after that what you have to do is once you log in you have to just click on this go to console just select that if you have never created any project in this one then you have only this one at project i've created previously three other projects that's why it's showing these all stuff so i'm going to click on this add new here you have to give some name so i'm going to name this one best project like this click on continue you have to name anything continue and i'm going to just disable this because for now i don't need these stuff and you have to just simply click on create predict will take few seconds and it will create the project so it's being created so throughout this curved operation i'm going to use a real time database and what is actually this real-time database let me just explain you click on continue and it will open this stuff and here you can see this test project is there and here we have real-time database so when i click on this it will open up that i look like this one and here we have the option create database before creating database let me explain you a bit about what is this real-time database so firebase real-time database data is stored as json objects this is not a relational database it doesn't restore the data in the form of tables rows and columns it simply stores the data in the json format so you can search on google what is exactly the json format is you can think of the database as a cloud hosted json tree there are no tables or records when you add data to a json it actually added to a json tree it becomes a node in the existing json structure with an associated key i will explain this don't worry don't be confused just follow us so when i click on this create database it will show like this you have to select the united state by default this one no no need to make any changes click on next select this one not this start in test mode we don't need that start in log mode click on enable now it will take few seconds and here you go now we will see a interface like this there you can see this first we have to make some changes in the rules so click on this rule by default you cannot read the data from this one and you cannot modify it you can see this read and write is false so what we have to do is just click on this edit over there delete this one true change this one to true and this one also to true like this and click on publish now the rule is changed now you can actually uh access it modified and other stuff you can perform okay so i've changed the rule now move back over here to the teacher and here first thing what we have to do is we have to just click on this plus sign because it stores the data in the json format so click on this one and first you have to mention the tables suppose you uh mentions in the relational database we have some table name so that's why there is one root name so i'm going to name this one teachers and i'm going to click on plus and here not this plus this time you have to select this one under this teacher there will be some id as i have told you that we have to this structure is associated with an id so there will be unique id so p1 will be the teacher id and this person not this time this one click on this one and here will be the name of the teacher the key value pair this is the key the value so name will be anything you can put the name j and now again other values like email this one and i'm going to name something email will be gmail.com there'll be another thing email and [Music] a professor of something courses of course maybe we take cse any subject and after this image url suppose the teacher url so p url and from where i'm going to fetch the image so let me search for any google it google any image and move back over here just use an image i'm going to use this one not exactly okay so we can use any image without okay so i'm going to use this one right click on this and i'm going to use copy image link and i'm going to paste it over this and you have to just click on add and here you can see this we have p1 with course email name t url like this one you can add other record inside this one by clicking the plus sign again you have to add p2 then plus inside this one and the same you have to make sure that you put these ids same okay so course will be p take and cse again email something here the is gmail.com then name will be something puja plus and the url i'm going to put the same image over here and click on add and here you can see this t1 and t2 so by this way we can actually add the data into this database that is real-time database this is a json tree and here we have ids for this particular record these particular this is key value pairs and there is different id for this one and this is a group that is teachers in the same way i am going to use this one not this one actually this one students so you have to create a table a json file like this and you have to modify the rules in the next video i'm going to show you how to actually fetch these data and show into the recycler view in android studio so stay tuned subscribe and share with your friends that's it for this video guys thanks for watching please like subscribe and share hello everyone welcome to my youtube channel in previous video i have already shown you how to create real-time database and firebase and how to set the rules for that so if you have not watched my previous video then just go to description there i put the link for my previous video or you could simply do one thing just click on the suggestion on the right side of the screen okay so here you can see this i've already set some data into this real-time database everything every these stuff i have already shown in the previous video so first watch that and after that continue watching this one so in this video i'm going to show you how to connect this firebase database with the android apk and how to face these data and also how to fetch this image and show into the android app let me just show you what exactly i'm going to show you in this video so i have started this my emulator is already on so my app is open so you can see this we have fetched the data from the database and the image is faced from the different links which i have stored in this one because it's a different link rahul puja sort of sameed there are six records and if we check in our app we have exactly six rahul for we take ec here you can see this it is being matched to abc android gmail.com and if we modify it the data over here is will be also modified okay so i'm going to show you how to exactly fetch these data and show into this recycler view for that just move back to this one and first thing i'm going to create a new project so that you start with a fresh you take a fresh start and understand everything so i'm going to click on new project select empty activity click on next and set some name so my name is fbase video face means firebase and i've selected the api 28 that is android 9.0 pi and language is java so just click on finish this will create a new project and this creation totally depends on your system configuration how much fast it will be done okay so mine is taking a little bit of time okay so now everything is ready okay so first thing what we have to do is we have to just click on this tool first thing we have to connect this our app with the firebase database so i i'm going to show you how to do that for that just click on this tools click on firebase make sure your system is connected with the internet while we are performing any task in the android because so many times it downloads something from the internet and if it can't able to download then it's going to show the exception so make sure while whenever you are working with android your system is connected with the internet so now you have to just click on this real-time database click on this get started with the real-time database click on this one connect to firebase click on this and this will open up your firebase console you have to log in with your account in which we have created the project so in previous video i have created this one but i'm going to use this f base because i have stored the data in the f base that doesn't make any difference so click on this one and it will start connecting it will take few seconds for sure [Music] you have to just click on this connect your android studio project is connected with your firebase android app now move back over here after this video click on this this will actually add dependency into your griddle so click on this and here you can see this griddle build boarding yeah now everything is now our stuff is added next thing what we have to do is just move back over here close this one we don't need this and over here open the project which you have created that is fbase for me just click on this and here you have to whatever name you have given just click on that and after that just click on this one click on the settings and here we find two project because my this the same database is connected with the other app as well that is the other project is f based let me just show you this one f based is connected with this one and for now i have connected with this app base video so just click on this and click on this one google underscore json dot sorry google dash json services.json just click on this it will download a file here you can see this just save this move back over here copy this minimize this one move back to the project click on this right click and paste it with this paste yeah there we go you can change the name i'm going to change this one to google and dash say services.json and click on refactor and overwrite yeah now we have this now our project is connected with the firebase database okay so you may not find that file which you have added right now when you click on this select project extend this and now here you can find this let me just yeah here google services dot json so now this one is added in our project this is very important file without this you can't able to transfer the data over there okay so next thing what we have to do is we have to add some dependency into this gradle build.gradle so just double click on this and move back over here some dependencies are added while we have connected this like firebase or firebase database and these stuff are added so we are going to use fuel dependencies these are let me just open this firebase ui real-time database uh for that we have to add the dependency this one okay com.firebase ui database and another is circle image and another is glide library we are going to use this light light library here you can read this glide support fetching and decoding and displaying video and images and animation gif we are going to show the image so without clay this is not possible to show the image so i'm going to add the dependency for this one this dependency okay so what i did is i have put all the dependency on in one place and my notepad and i'm going to just copy these all and i'm going to put this in the android so this one and i'm going to just make some space for that and i've also used recyclerview card view to create the card view is to actually create the item each item view for the recycler view okay so i guess five is two time i've added so let me remove one i'm going to remove this one okay so firebase ui everything is ready now you can also pause the video and write it manually or you can search it one by one and just click on this sync now it will take few seconds download all the dependencies and now my stuff is ready next thing what we have to do is now our dependency is added so next thing what we have to do is i'm going to provide the link for these all three urls so that you can add the dependency from here in the description of this video so just check out that okay so next thing we have to move to the manifest and just double click on this and here we have to add the internet access uh give the internet permission to this app because this is going to face the reader from the firebase without internet that's not possible so for that you can just write user permission android name is android permission dot internet like this now you have to just save this and close this next thing what we have to do is we have to move over here so let me just minimize this one go to resources layout and first thing we have to add a recyclerview so let me get just get rid of this one and go back over here search for recyclerview here you can see this just drag and drop it over here and just click on this to constrain these from all side because if you don't constrain it it will show an error click on a split and we have to set some id for this one so i'm going to set the id so id will be rv that is recycler view so now this recycler view have some id now move back to the main activity and here we have to register this so cycler view like this one next thing recycler view is equal to we have to type cast this cycle view find view by id r dot id dot and we have put the id rv after this what we have to do is we have to just write recycler view dot set layout manager and inside this one we have to set new linear layout manager and we have to write this okay so for now the task for this one is done next thing what we have to do is we have to create a model class model is nothing but which type of data you are going to fetch we are going to fetch the four data from our firebase so let me just show you that is codes email name and url so we have to create the model for according to these data so move back over here and just right click on this click on new select java class and here we have to write i'm going to leave this one main model and just hit enter and inside this one we have to just create four variables string and one is name another is course and another is email and it is surl s url okay so make sure these uh name are exactly same as this one that is course email name as url order making can change but the name an ame course c-o-u-r-s-e e-mail e-m-a-i-l-s-u-r name are saying after this what you have to do is you have to just click on alt and insert and we have to just select the getter and set us and select all by pressing the serial key and click on ok this will create the getter and status and after this we have to again press the ctrl and insert key sorry alt and insert and if you just click on constructor just click on ok now our constructor is also ready and one more thing what we have to do is we have to just create a one zero or constructor that is for firebase so we need that so you have to just write like this okay so now our model class is ready here you can see this we have the getter and status and we have the constructor with the arguments and one default constructor with zero arguments so let me just close this after this we have to just create a new item so that we can see let me just show you here inside this one this is a recyclerview and here we have one item that is that there are different items with sorry the same type of items with different data so this is one item in the recycler view this is another uh item in the recycler view this is the another view in the recycler view this is another view in the cycle so we have to create one view inside the recycler view for that just move to the layout just right click on this select new layout resource files like this one and i'm going to name this one name underscore item and click on ok and this will create a view like this i'm going to click on a split and i'm going to use this one i'm going to use card view for this one [Music] so just change this one to [Music] card view cardio widget card view this one okay so let me just move this a little bit wrap content height will be wrapped content change this one to trap content i have to set few more properties for this one that is card corners corner radius will be 6 db and elevation it will be 6 db and after this we have card use compact padding just change this one to true now everything is ready for this one okay so now we have to add few items that this one because we need one circle image and three text boxes to show the data so all this data will be put inside the related layout and this will be match parent for width and wrap content for this one height and we have to set the padding so padding will be of 15 db like this inside this uh relative layout we have to put the circle image view first so i'm going to put the circle so we have added the dependency for this one so that's why it's showing on the top if you can't able to see this it means that you haven't added the dependency so add that dependency just double click on this and this will ask for the height and width so i'm going to set the 80 tp and the height all will be 80 dp like this after this i have to set the source for this to check the default image so i'm going to set this one yeah here you can see this image is visible over here and i'm going to set the layout center vertical let's go center vertical and change this one to true and i have to set the id for this one id img one and i have to set this civic border with 2dp and you have to set the border color hashtag ff like this and finally close this one so now our image view is ready to show the image we have set the id also next thing we have to put one text now that is with the name so i'm going to put that text view and this one will be match match parent and wrap content okay so it will be id for this one that is txt name or name text after this i'm going to set some text for now so that will be student name and to set the text style that is bold after this i'm going to set the text size 25 sp and text color will be black so for that either you can set as 0 0 or you can set simply text color black so layout is a relative layout so we can set where exactly this needs to be right off id img one so now here you can see this this is on the right of this one and i have to set some margin for this one so margin left left will be 10 db like this yeah this one is looking nice after this we have to set the for one more for the another that is email id and course so i'm going to just copy and paste it once again and i'm going to change the id for this one this will be course text and this will be course name [Music] 25 sp not polled this is this will be normal so i'm going to just delete this and this will be not right up this is right of image and you have to set this one below layout below and the red id and id will be named text like this this one is looking nice the margin will be 10 db now again we have to copy this once again and paste it over here and we have to change this one to course text from course text to email [Music] email text and this will be email id and this will be below off below codes text like this now this one is looking nice and our view is ready now our menu item is ready so now we have to just set this into the recycler view and we have to show the data okay so for that we have to create the adapter class so move back over here right click on this click on this java class and select main i'm going to name this one mate adapter click on enter after this what we have to do is now our raptor is ready so next thing we have to write over here extends firebase recycler adapter and before we do anything we have to create the view order class so i'm going to name this in class my view folder this will extends recycle view dot view holder like this one and inside this one we have to register the circle circle image view and it will be img and we have three text view text to view one is name another is course another is email and now we have to actually just click on this create constructor matching super my window class now this type of stuff is will be created and inside this one we have to register this img first img is equal to we have to type cause this so to circle image view then we have to find that view from item view dot find view by id r dot id dot img one like this and after this we have to set the name so name is equal to and this is a text view and again from item view dot find u by id r dot id dot text name like this then we have course is equal to text view item view dot find view by idr dot id dot course text finally we have email is equal to text view item view dot find you by id r dot id dot email text like this one after this what we have to do is we have to just move back over here just click on this and we have to write like this our model class main model you can name whatever you have set the model name so main model dot comma sorry main adapter adapter and we have to fetch the my view holder like this one after this just click on this and implement methods select all these two click on ok and now two methods which we have over here and again if you click on this create a constructor matching super just click on this one and this will create a constructor over here this one okay so number constructor is also ready and we have two methods again now first thing what we have to do is we have to just move back over here in the view holder on create and here we have to bind this view that is main item with the recycler view inside this one so just click enter over here and go to right view view is equal to layout inflator dot from and where we have to get this parent view group here you can see this view group this parent is over here parent dot get context and outside this one dot inflate r dot layout dot and our item name that is i have given this main item and we have to put comma parent we have to pass these stuff and finally the faults like this attached to it and finally we have to return this view so i'm going to just replace this with new my view holder and we have to pass this view now move back to this on view on bind new holder and here we have to write few lines of code so we have to write like this we have to use this holder that is my viewer type so one right use this order dot name dot set text and we have to set the text that is from the model dot get name in the same way we have to set for other so holder dot co start set text and inside this one we have to write model dot get course finally we have to write this folder dot email dot set text model dot get email like this one and finally we have to use the client temporary so glide i just added the live dependency for that so i can use this glide dot width and here we have to use this holder dot img i'm going to set the image so img dot get context and so this one i have to load this dot load model dot get s url we have set the name as url and after this dot placeholder i'm going to use this r dot driver if there is no image so i can use this anything c o double m o n underscore google sign in button i can dark i can use it for default i can use this and circle crop it will be and if any error occur then again i want to see something so r dot tribal dot com sign in button i can talk normal okay so if there is anything error occurs if it can't able to load the image so it will show the image this one this image you can see small g over here so it will show like that if that shows in your system then there must be some error you have to see it or search it on google and just into holder dot ing so now that's it so now we have set the image and we have did all the binding we have created the constructor default constructor so now our adapter class is ready finally what we have to do is we have to move back to our main activity so move back over here and here we have said the recyclerview so we have to actually put some code over here to actually fetch the data from the recycler sorry fix the data from the fireworks and sew that to the recycler so for that i've already provided the link for this one so for that just click on this real time database and you have to just go down here you have to copy this code that is fiber recycler option chat this chat is not nothing but this is the model class where you have to pass the model class so just copy this and move back over here and just make some space and paste it and in the chat what we have to do is we have to just change this one to our model classes main model so we have to change this one to main model and we have to actually just enter alt enter import class and we also have to import class for this one alt enter okay so we don't have this query okay not not an issue i don't need that set in the place of query we have to write like this firebase firebase database dot get instance dot get reference dot child and we have to pass the database name sorry so move back over here and here you can see this this one this name you have to pass over there that is students so i'm going to write the students over here the double quotes make sure the spelling that word is right and change this one to main model stuff is main model also we have to change it over here so main model now our error is gone we don't have any error and finally we have to write few more line that is main adapter okay so we don't have created the adapter variable over here so i'm going to create one main adapter main adapter like this okay so main adapter and we have to write like new main adapter and inside this one we have to pass the options this variable from here and finally we have to connect to this recyclerview dot set adapter we have to set the adapter and this is main adapter okay so now the stuff is ready i guess i missed something in the dependency so actually i have to add few more to more line of code so i'm going to add this you have to uh paste this outside this uh after closing this regular sync now and move back to the main activity and here we go so now our code is ready everything is set and done so let's start this and let's check if this one is working or not so open this this is f base this time it should be fbase video and the data will be same you can see this f base video and let's see okay so let me close these two once again and let's check open this once again so there must be some issue let's check that okay so what's the issue at default route okay let me just check that if my internet is working or not yeah and my internet is working we said in our error opening okay so what we have to do is we have to put some more line of code we have to just enter alt insert and we have to overwrite some methods that is on start and we have to override this on stop select these two and click on ok and on start what we have to do is we have to perform some operation that is start listing so super dot on start main adapter dot start listening and on this one we have to write main adapter dot stop listening like this now start this and now check this if this one is working or not just open yeah here you can see this f base video let me just close this and rest start this one f base video okay here you can see this this is working and now d is being fetched from the database and it's showing over there so now move back over here and where is my database and here you can see this i'm we're just going to change this abcs gmail.com to rahul at their achievement.com let's check this if this one is updated or not if i hit enter and move back over here you can see this gmail.com so now i have we are literally be sure that this data is being fetched and shown over here so this is at this video here you can see this and another another app is fbs video so both are different and working very fine okay so the next video i'm going to show you how to search in data instead of this one and after that i'm going to show you how to edit update and delete the data from this android app with the data inside this one so till then subscribe share with your friends thanks for watching hello everyone welcome to my youtube channel in previous video i have already shown you how to fetch the data from the firebase database and show that in the recycler view here you can see this the data is being shown in the recycler view so if you have not watched that video then just go to description there i put the link from my previous video or you can simply do one thing just click on the suggestion on the right surface screen okay so in this video what i'm going to show you i'm going to implement a search box over here so that we can search the uh any student by name so i've implemented that in the f base so let me show that here you can see this is f base the data is being fetched and here we have this one if i want to search for row head then if i type like this android is visible for our two names are there if i cut this no one is visible sorry everything is visible when this search box is clear okay so let's start implementing this one so let me minimize this first okay so this is our f base video inside this one nothing is implemented for now here you can see this there is no search box this is where we left in the last video so let's start with that first thing what we have to do is we have to add one folder inside this package so click on new select the directory and i'm going to name this one menu hit enter inside this menu i'm going to add new menu resource file click on this and i'm going to name this one search and click on ok this will add a file like this click on a split and here we you find the code so here we have to write some line of codes so that will be the item and item i'm going to set the id for this one search after this i have to set some icon so before we set the icon we have to actually create a layout driver for this one so right click click on new travel resource file not drivable resource file actually right click click on new vector asset click on this one type here search click on this one click on ok and change the name something which you like so i'm going to change this one to search underscore icon and click on next and click on finish and here you can see this for search icon the code is already added inside this one so let me close this search.xml and here we have to set the icon so i can will be drawable search icon this one after this we have to set the title for this so i'm going to set the title search and i'm going to show as action and you can set if room always always means that search box search box will be visible over here and if room there are so many options over here then if there is space then only this will be visible so i want to show if i select this never so always this will be under this three dots okay i will change it and i will show you action view class you have to search for that there we have and fitkit search view and we have to convert this into android x so we have to just write app call like this one we have to remove this android part okay so not like this i have uh so as action after never for now i'm going to change this later okay so after this now we're designing part for this one is ready so next thing what we have to do is we have to move to the main class main activity for now if i start this one let's see what will what it will show so for now it's not showing anything over here so let me just minimize this and we have to put uh sorry add fuel line of code over here so first thing we have to override one method that is for that insert and here we have to override a method you have to search for on create option option menu click on enter and here you can see this on create option menu is over here so here we have to just write you more line of code that is get menu inflator dot inflate and we have to inflict with the id so r dot id dot search we have set the id for this one is this one yeah search here you can see this so we have to write that search and where we have this in menu okay so why this is showing an error let me just check that let's put this resource for inflate okay it's not r dot id it's r dot menu okay so now this is fine after this we have to create object of menu item this one and item is equal to menu dot find item and inside this one we have to pass the id so our dot id dot search and after this we have to create a search view search view is equal to and we have to type cast into search view and item dot get action view like this and finally we have to create set on query text listener for that we have to apply that on search view dot set on query listener and now new search view and when you type this you will find this first one on query text listener in this bracket curly braces double click on this and this will write this fuel line of code for you that is two methods over there and inside these two method we have to create we have to actually write something before we write anything inside this one first we have to create one method so i'm going to create one method so private void and i'm going to name this method txt search and i said this one this will take one variable string str this is our method and inside this one we have to actually copy this code this code actually being fetched and this is being actually fetching the data from the firebase database and which we are using to show into the recycler view so i'm going to take that code from there and finally what we have to do is we have to actually change few lines of code over here so after this child and the student we have to write dot order by child and we have to pass the column name so i'm going to do we are going to research by name so i have to write some names okay so minimize this part and start at started str dot and add str plus and we have to write like this this is the end character so we have to put some character over there okay so order by child and start this is a str whatever text being passed from here will be according to that data will be fetched okay so we have to make some changes over here so [Music] that will be value five is likely to view everything is fine we don't need to make any changes okay so here we have to write main adapter is equal to new main adapter and inside this one we have to pass the options this one okay after this we have to set start listening we need to provide start listening recycler view we have to set the adapter inside this one so main adapter again we have to set this now our method is ready after this what we have to do is we have to just simply call the method inside this one okay so inside this one txt search and we have to pass the query this query and again i'm going to copy this and move back over here paste it over here it will show an error i'm going to change this one and query okay so now everything is ready so let's check this if this one is working or not so start this and here we go here you can see this there are three dots when i click on this then this search appears so when i click on this one okay this is not cool so move back over here call face change this one too always and search here because it is done directly magnifies classes here so we started it again if i click on this now here we have this so if i search for rahul this is r if i type like this a this is an omega and we can actually change this according to if we want to search by email id so you have to just move back over here and change this one just change this one to email and now restart and search by email like our a yeah abc there is no abc bcd is there yeah vcd here you can see this bcd is an email so we are actually able to find it by the email id you can change accordingly as per your need so i'm going to leave it as name okay so what actually i am going to show over here is what this is so as action if i set it always so it will be always over here like this one if i change this one to never or if room collapse acts and view okay so if set this with text and let's start this and let's see how actually this one look like now here we have the search if i click on this this is not working i will check that out once again but if i change this one to always and if room so there is a space for this one so it will be available over here you can see this okay so i have shown you how actually this function when we change this one the available option we have to change this available option you can check for the other as well so i'm going to set this always for now and just start this and this one is working fine so that's it for the video guys in the next video i'm going to show you how to edit and update the data from android and the data will be edited and updated and deleted as well in the firebase relation real-time database so thanks for watching please subscribe like and share with your friends hello everyone welcome to my youtube channel in previous video i've already shown you how to add the search bar over here when i click on this a text field opens and here we can type anything to search so i'm going to search for rohit so here you can see this when i type ro it shows the complete detail of that so in previous video i have shown you how to implement this if you have not watched that video then just go to description that i put the link for my previous video or you can simply do one thing just click on the suggestion on the right side of the screen okay so in this video i'm going to show you how to add it and delete button for every item in the recycler view when i click on this this one i've already implemented that part here you can see this i have slightly changed the color for this one here i can delete the record i can edit the record when i click on edit a new pop-up is here you can update the data like this here you can see this rahul kumar and click on update and here you can see this now this is rahul kumar if i close this application and if i reopen it and still you will find that the name is raul kumar even i go back to this this one that is firebase video on which we are working so here you can see this here the name is also updated because both app is fetching the data from the same firebase database okay so it means that update is working and i'm not going to delete any data for now and i will add one dummy data and after that i will delete that one okay so i'm going to start this how to implement so first thing what we have to do is we have to add this edit and delete button for this in this menu items in previous videos i have created this menu item so you have to go through all the videos and complete the task till here at least over here after this we are going to proceed with that one okay so i'm going to add elite and delete button and shoot this one so let me minimize this one for now so move back to this menu item just double click on this and here you can see this till now we have this we don't have any button inside this one here you can see this we have only student name course name email id and one image so i'm going to add one linear view inside this one inside this related layer i'm going to add one detail view sorry linear layout actually linear layout and the height and width will be match parent and wrap content and after this i'm going to set the orientation and that will be horizontal [Music] not like this you have to close like this one okay and we have to set this linear here you can see this this legion layout is in the top of this card view so what we have to do is we have to set this below this email id or yeah whether this email id or below this image so let me try both layout underscore below and id for the image will be something yeah id in img1 oh not this one is not good i'm going to set this below email text and yeah this is good and inside this linear layout we have to add two buttons so i'm going to add two buttons so that will be button and height and width will be 173 db width and height will be wrap content i'm going to set the text for this one that will be something approx no this is the text right so i'm going to say this one first one is edit and after this we have to here you can see this every text is in the capital format so i don't want i have written it only e in capital and remaining is in small but it still is showing in capital so for that we have to write text all caps and make this one false now you can see this now it is in the same format and after this we have to set the layout margin that will be the right margin let me set this one 5 db and i'm going to set the id for this one id i'm going to set btn edit like this one now for this button the task is done i'm going to copy this once again and paste it below okay first thing we have to change the name that is the id i'm going to change this one to delete and change the text also to delete this time we don't need the right margin we need the left margin like this here in the center you can see the spaces right okay so next thing here because we observe that the image is now below this button i don't need that for that what we have to do is we have to actually delete this one layout center vertical true just delete this and here you can see this is on the correct place okay don't worry about the color i will change the color later okay so now the design is ready if i start this and let's check if our design is ready or not okay this is a face and a face video here you can see this for now the button is added it means that this is working but we can't perform any operation because we haven't set anything on the click listener of this button or is this one okay so next thing what we have to do is we have to start designing the pop-up which is being open when we click on the edit button okay so first we are going to code for this edit here you can see this when i click on this edit a pop-up will be here for that we have to start with this okay so first thing what i have to do is i have to add one dependency into this build.gradle so double click on this and just go to site not this one this is my firebase so you have to go over here https colon double slash github.com and whatever this is we have to use dialog plus okay so i'm going to provided this link in the description of this video okay we have to go below over here and just copy this line minimize this move back over here and paste it and just click on sync make sure your system is connected with the internet okay so now this is synced right now so we have to use this dialog plus this makes our stuff really easy to view a pop-up okay so we move up back over here let me just close this because we don't need now we have set the id for these so let me close this move back over here so first thing what i have to do is in this app you can see that for the textbook there is some boundary some color and the corner is curved right so we have to set that we have to create one drawable file for that to set this one okay so for that let me just create one just click on this drawable right click click on new drawable source file and just name this one i'm going to re name this one rounded enter and here we go inside this one we have to set some rules some stuff like solid this would be after this android and we have to set the color so i'm going to set this one hash and six times no yeah six time f just slash you can change the color this is really right and we have to set the stroke and we have to set the width i'm going to set the width 1db and android colon color will be this is the color of the border at 2 f 6699 you can change according to your requirement okay and i'm going to set the corners and radius this actually describes how much curve you want in the corners okay so i'm going to set this one 10 db just save it not just change this one selector to shape and now you can see the shape if i change this one to like 35 you can see this the corner is more curved now with the help of this radius we can set the curve of the corners so i'm going to set the 10 minimum you can see this the color you can change the color by clicking on this and selecting the different color composition but i'm going to just use this one just save it and close it next thing what we have to do is we have to create one more stuff that is nothing but that pop-up so for that just click on layout right click on this new layout resource file i'm going to name this one update underscore pop-up click on ok and it will create a design like this the empty one just go to split and here we have to start with the changing first this constraint layout to linear layout linear layout and orientation will be vertical because we are going to put the data sorry the fields and text fields next to you one another below okay so i'm going to set the orientation to vertical next thing i'm going to start the controls inside this one first you must have observed that we have when you click on this here we have update details so we have to create this view this one so i'm going to create one view over here so that will be text view and the width will be match parent height will be 50 db and text will be update details [Music] after this the background we have created one no not one i'm going to set the color that is purple's 500 okay and after this text size will be 25 db so that it needs to be visible gravity will be center and text color will be white i'm going to write the code for that ffff yeah here because this is white now close this now i've created one text view next thing we have to create two more one text view and another text field right edit text so i'm going to create one more text view this will be match parent and this will be wrap content gravity will be center and after this text size will be 20 sp and layout margin top i'm going to set this one to 5 db and margin top and bottom will be also 5 db and finally i'm going to set the test and this will be the name the first one and here you can see this we have the name over here okay so after this vd1 edit text so i'm going to add that detection width will be match parent height will be 35 db i'm going to set this and i have to set some margin so i'm going to set the margin left to 10 dp and margin right to 10 dp and i have to set some rounded corners which we have created earlier 10bp like this okay so background will be at the right drawable around it and here you can observe now we have something right rounded corners here you can see this we have the rounded corners after this i have to set the gravity to center it means that whenever any text we start typing inside this one will be in the center of the screen so i'm going to write the center and i'm going to set the id for this one so id at the right id will be txt name for the first one and just close it after this i'm going to copy this four times to save our time little bit one two three four right it's so sorry it's five times okay four yeah so now what we have to do is we have to start changing the names only so first name and after that we have course and i'm going to name this one txt course below this one below course we have email id [Music] and i'm going to name this one txt email below this one we have [Music] first sorry this is name actually i have by mistake here i have changed this one first one is name and this is pxt name second one is okay first one is text name second one is course and ids txt course below this one we have email id to change this one to email id and txt email after this we have profile url okay so for this one i'm going to name this image url and change this one to txt image url like this now we have done with the text fields now we need to add one button that is will be the update button right so for that we have to write like this button and this will be match parent and height will be wrap content after this we need to set text that will be update right after this we need to set some margin from the left top as well left right first so margin left will be 25 db margin right will be 25 db [Music] and we need also some margin from the top so margin top will be 10 db that's looking nice okay after this we have set the text and we have to set the text size text size will be 21 tp this is looking nice text all caps we need to make that false after this we have to set the background so background will be add the red drawable rounded and gravity will be center after this we have to set the id for this button so id id and it will be btn update [Music] now our design is ready next thing what we have to do is i have shown that we have changed the color for this design okay for now here you can see this for this one the design the color pattern is different for this top and this one and as well as parents so i want to change the color first so for that we have to go inside this one values and double click on colors you may don't see this interface like this one you may see the primary color and the secondary color something like this not to worry you can select the color from here and in the same way you have to change the color code over here so i'm going to change this one to hash 0 da 8 9 e and the second one that is purple 700 i'm going to change this one to 0 0 six triple it sorry double hp and now save it and now start it once again and you will find that the color for our f base video is changed now and here you can see this in the f base video now when i click on this nothing happens but the color is changed okay so now they move towards implementing these edit and update button for that we have to just go back inside this one that is the main adapter we do don't need to change anything inside these two just move back over here and here we have this already these code are written in my previous video so if you have not watched that i will recommend you to watch that videos so below over in below here you have to go to this my view holder class inside this one we have only access these image name course email but now we have added two more stuff that is buttons so i'm going to link that access that buttons also so these are buttons so we have to write buttons and this is bdn edit and another one is bdn delete like this below here we have to access also so bdn edit is equal to and we have to type this to button i need to use item view to access it by id item view dot find view idr dot id dot pdn hit it like this bdn delete again type cast 2 button after this we have to type item view dot find view by id r dot id dot btn delete like this now the task till here is done next thing what we have to do is we have to move back to our onbindviewholder inside this one and here we have to do the remaining task so first thing what we have to do is move back over here and make some space first thing we have to bind that the view which we have created that is update pop-up which we have created we have to bind that with the edit button for that what we have to do is we have to just move back over here and use the holder here you can see this but by using this folder we can my view holder we can actually access and set all the values to those text fields and any stuff other stuff so by using this we can actually perform the edit operation for a particular item in the recycler view okay so holder dot btn edit i can access it you can see it right now and we have to set on click listener new view on clicks and when you type capital v you will find this first one just double click on that and it will implement a method for you here you have to simply write i'm going to use this dialog plus for that i have already added the dependency inside this one here you can see this dialog plus independence is added and my app is also synced so if you're facing any issue while syncing the application you must make sure that your system is connected with internet okay if for the first time if your system is not going with internet then you have to just close the application and restart and then try again to sync it okay so here i have to use final and i have to use dialog plus [Music] and inside this one you have to type holder dot img dot get context dot set content holder new view folder inside this one we have to pass that layout so r dot layout dot update pop-up and after this we have to type set expanded and inside this one we have to pass it true and the second thing is the value how much size for that one the pop-up and just finally type create that's it and now what we have to do is we have to show this for the first time without what i want for now is when i click on that edit button and this one when i click on this edit button now i just want this pop-up needs to be open without any data for that i have to simply write dialog plus dot show now restart the application move back over here and here you can see this when i click on this now the pop-up is here the height that is 1200 we have said that 1200 from below to here you can see this is this is 1200 if you change this value this will be more or less according to the changed value okay so now what i want is when i click on edit the data for that particular person will be fetched from the firebase and shown over here and when i click on update which i need to be able to update it okay so minimize it and now let me just comment this for now now move back over here and we have to create one view so view view is equal to dialog plus dot get holder view now we have you over here first thing we have to access all the text fields inside this one here because we're going to click on this we have text fields and we have set the name txt name txt course txt email txt image url so i'm going to access these so minimize this with the help of you we can do that edit text name is equal to view dot find view by id r dot id dot txt name like this after this we have edited text and we have course is equal to view dot find view by id r dot id dot txt course with text and we have email is equal to view find viewer id r dot id dot email txt email after this we have edit edit text and we have s url that is student url is equal to view dot find view by idr dot id dot txt image url like this after this we have now we have accessed all the text fields now we have to access the button that is the update button so for that button ptn update is equal to view dot find viewer id r dot id dot ptn update like this one and now when i click on that button before clicking on that button we have to actually extract the values and set that value into the particular text fields when i click on the edit the data for that particular student needs to be fetched and set into the that dialog box okay so for that i have to set like this name dot set text model this is the model class this one that is main model inside the main bottle with the help of that if you already have the access with the main model here you can see this with the help of this we can actually uh there is a predefined sorry we have defined some getter and setters with the help of that we can actually access the values so dot get name and after this course dot set text model dot get course after this we have email dot set text model dot get email after this we have s u r l dot set text model dot get s url like this now we have to just show this pop-up so dialog plus dot show now let me restart it and let's check if the data is filled again or not this time previously the data is empty when i click on this yeah here you can see this is trouble kumar ptek image sorry the email id url and everything is here when i click on this nothing happens when i click on back this is closed next click on pooja yeah the name is visible and the data is being changed here you can see this is an amica feeling cac gmail.com yeah the data is being faced and being shown over there next thing what we have to do is we have to perform the click operation on the update so for that let me just minimize this move back over here and just make some space now we have to just perform the operation that is vdn update dot set on click listener view v1 sorry not this one do you want click listener like this here we have to create a map of the object because this map is is actually passed when we update the data so first i'm going to create one map object so map this is where the value of string and second parameter is object like this i'm going to name this one map new hash map like this one and we have to put the value so map dot put in the key value pairs the value is being stored so first that is name make sure this is same as which is in your firebase database so here you can see this move back over here we have course email name yes url so we have to put the same okay so we are working with this one name dot get text dot string we are actually extracting the values from the text fields when we click on update we have to re extract the values from the text fields might be users change the values so map dot put and the same we have to use course like this map dot put this time we have to write email email dot get text dot to string map dot put inside the email next next is surl s url dot get text dot to string now we need a instance of firebase database for that we have to write firebase database for this we have already added the dependency in our previous videos so we can directly access this so firebase dot get instance dot get reference dot child so in the child we have to actually pass this value this is the student the root root value this is students in my case if you have changes value then you have to write the same one so i'm going to write students like this now we have to just write child and send this one get ref and we have to pass the position from where i get this position inside this onbindviewholder we have position okay so move back over here the position is now we need to get the value so that get key and now dot update children and we have here because he doesn't update children when i write sorry let me just undo it space update children inside here you can see this it's asking for one map so i have to pass the map inside this one now the value is added inside this and now we have to check that if the data is successfully added or not for that we have to write dot add on success listener and new on success listener like this one when you click on enter a predefined method sorry the o it will override a method on success and here we have to actually create a post which will so data is successfully added and that dialog will be dismissed okay so i'm going to create a toast create tools and here it will find for some context so i'm going to get it from holder dot name dot get context and say the text i'm going to pass update it successfully data updated successfully it updated successfully and here we have to and just put dot add on [Music] failure listener new view on click no not this one new on failure listener like this if you have to copy this again [Music] this toast i'm going to copy this toast and paste it over here and i'm going to change this one to error [Music] while updating okay so this toast will be visible whenever we update or update and if there is update will be successful then data updates successfully and if there is any error then it will show not updated successfully okay so here it's showing some short of error so what i'm going to do is i'm going to just remove this part now this is good and here i have to add so we need to actually close the dialog also so time log plus dot dismiss why i put this dialog plus dot dismiss let me just comment this and let me put one comma over here semicolon now start this and let's check if this works or not edit so click on this edit and i'm going to change this one to rahul for now and just click on update and here you can see the data updated successfully but this pop-up is still open so if you want to close it when i click on this update after showing the toast message then you have to write this dialog plus dot dismiss i have just commented this line that's why it's not hidden we have to manually minimize this if i back click on back whole application is closed this is a very bad way so i have to just uncomment this and just move back over here and this time i'm going to edit it change this one to k update it and here you can see the data updated successfully and this is minimized the same way we have to add over here if there is failure so we need to just show the message and dismiss after this what i have to do is i have to add i have to code for this delete button so update is working fine here if you see this event trowel k we can check this with the firebase here you can see this we have round k now okay so minimize this and move back over here below here we have to now start for delete button so holder dot btn delete dot set on click listener new view on click listener and here we have to start with the coding so first we have to create one alert dialog box so whenever you must have seen a pop-up something like let me just show you okay so alert dialog and let dialogue dot builder builder is equal to new alert dialog video type this one we have to pass the whole dot name dot get context we got the context and we have to set some uh title for that dialog box so builder dot set title and the set title i'm just going to ask the user are you sure you want to delete are you sure [Music] yeah that's it and final description dot set message i'm going to show some message to the user deleted data can't [Music] sorry can't be undo it means it's the final warning if you delete the data you cannot undo or regain that data okay after this we have to set builder dot set positive button and this will be deleted i'm going to name this one delete and you have to say new dialog interface on click listener when we click on delete what you want to perform the operation and when you click on cancel i need two buttons so one is for delete and one is for cancel so negative button and i'm going to name this one cancel new dialog interface yeah now this is ready and after this i have to show this builder dot show because without this you can't show that alert dialog box okay so on when i click on delete i have to read the data and if i click on this cancel nothing needs to be happen i just want to show the toast so let me i guess i have copied the toast yeah i have it so i don't need to be like magic so i'm going to write like this toast and here we have to get the context so for that i'm going to use a holder dot name dot get context and the text is cancelled that's it now let's start for delete i have not written any code right now so back over here click on delete and here you can see that you show deleted data can't be undo if i click on cancel that builder is closed and if i click on delete for now nothing happens because i'm i haven't written any code inside this one so i'm now i'm going to write some code over here to delete that data so firebase database dot get instance dot get reference dot child so this one we have to write student root dot child get reference now we are going to access the id over here you can see this under this students we have separate ids s1 s2 s3 s4 s5 and s6 there are different ids so with the help of this id we can delete a particular record because these are unique for each record this one record this is second record this is third record and we have to access this one so how to access that for that we have to write now we have access this students below this we have to write dot child dot get reference and we have to pass the position position dot get key when you write this now we have access to that s1 s2 and whatever the data whenever we click on that we have to just write remove value now this code is fine now move back over here i'm going to add a dummy data so just click on this plus s7 and finally plus this one [Music] suppose will be mba just click on this email something avc gmail.com plus and name will be abc and s url i'm going to just leave it null for now click on add and s7 is added now move back to the app and let's check here because it is s7 abc mba i'm going to click on edit here to see this image url null so this g is being visible because for the error we have set the gmail icon over here so what i'm going to do is i'm going to just copy the image from the scrollet and i'm going to paste it inside this another one so select all just keep on clicking copy minimize this back oh move back over here edit this paste it click on update and when you click on update now you can see that abc is also having the same image which rohit app so now when i click on delete it will ask for are you sure you want to delete if i cancel nothing happens cancel this shown over here if i click on this delete and click on delete and here you can see this now this record is not gone why this happens you just close this open this once again and move back over here okay we miss we must have missed something so students the partition dot get value get key remove value everything is fine let me check this is not working because we are passing this position where it is let me just yeah here we go we are passing this position in the inner class because this this is the inner class that's why we cannot pass the value directly the from outer class value we cannot pass directly to the inner class for that to pass that value and work correctly we have to make that variable final so what we have to do is just move back over here to the top on by viewholder and we have to make this one final and now restart the app and let's check this here we have abc we can actually make changes abc kumar like this and click on update uh this is being updated here you can see this abc format is here when i click on delete cancel yeah cancelled this is working fine delete and click on delete yeah the record is deleted and back over here in the firebase you can see this one the s6 is over there if i click on this and click on update data updated successfully is over here you're not getting any error so that's fine everything is working now read we can actually update the data and we can also perform the delete operation so that's it for this video guys in the next video i'm going to show you how to actually add the data in that firebase through the application till now we have added data manually over here but the next video i'm going to show you how to do that from the application so stay tuned subscribe and share with your friends thanks for watching hello everyone welcome to my youtube channel in previous video i've already shown you how to add edit and delete button in the recycler view and how to perform operations when i click on this edit button and when i click on this delete button so if you have not watched my previous video just go to description there i put the link from my previous video or you can simply do one thing just click on the suggestion on the right side of the screen okay so in this video i'm going to show you how to add this floating action button over here and when i click on this a new activity is open and how to perform the save operation in the firebase so suppose if i'm going to add a new data over here so i'm going to add a tom and he's in btec and the email id is tom there gmail.com and i'm going to take one image right click and just copy image link click on this and here you can see this for now i don't have any tom so i'm going to add one tom over here so for that to actually paste in this one just long press same as we do in our cell phone and paste it save and here you can see this new data is added this is not this one this one so i'm going to show you how exactly we perform this operation now move back and we will find we have tom over here now the image is fetched and it's being shown we can perform the edit operation as well and we can delete this record as well so without wasting time let's start with this so we are working on this f base video and inside this one here we can see we don't have any floating action button so first thing what we have to do is we have to add one view that is a one activity actually so i'm going to add one activity in this one let me close this and minimize stop this okay so first we have to add one activity which is will be opened when we click on that proving action button so go to activity click or select empty activity click on this and i'm going to name this one add activity click on finish this will add a new activity a new class and a new xml file layout over here you can see this we have new okay so we don't need to perform any operation on this one for now let me close everything close all okay after this i have to add one drawable file i'm going to add one vector asset click on this and click on this one and search for add select this click on ok and just change this one to add underscore new click on next and finish the new xml is added for this plus after this move back to this one that is activity main because in the main activity we have to add one floating action button so move back over here on the palette and search for floating action button just click on this drag and drop it over here next thing what we have to do is we have added a new xml that is add new here you can see this select this and click on ok and now we have this now just drag like this we have to constrain this on the call side all foresight and we have to bring this on place like this wherever you want to place just place it now here you can observe that this floating action button have some default color so i want to change this one to red or orange so i'm going to set the this background tint and i'm going to set the color code that is hash ff8400 and now here you can observe the color is changed okay wait for a minute back over here it's black right now oh sorry i missed the hash so it's hash yeah now you can see this this is orange and it's looking nice but when we start this and we observe that we don't have this floating action button in the app it's being started oh okay now we have it when we click on this nothing happens okay so we need to move this one a little bit on the right side okay so now we have to register this in our main activity so move back over here in the main activity and here we have to type floating action button floating action button like this and we have to set the quick listener on that so for that we have to move over here floating action button dot set on click listener new view on click listener and inside this one what we have to do is we have to open this add sorry activity underscore add whenever we click on that plus that is floating action button okay so for that what we have to do is we have to just write a one line of code that is nothing but start activity not activities start activity make sure you write this one and after this new intent get application context dot sorry comma and we have to name the add activity dot class like this now start this and let's check if something happens now when we click on this add sorry floating action button okay so it's having some issue actually we haven't registered this floating action button so floating action button dot dot dot is equal to floating action button find u by id r dot id dot floating action button like this okay so the id for this floating action button is by default set whenever we drag and drop it let me just show you that in the main activity activity main when i click on this and go to split code here you can see this floating action button id is to by default set inside this one we haven't set the id but it's set for this one okay now if we start this now our app is started when i click on this it's open a new activity with the empty because we haven't added anything in the ad activity underscore ad so now i'm going to add text fields and other stuff into this one but i'm going to copy the code from this in the previous video we have created update pop-up and i'm going to copy all from this and move back over here in the activity to underscore ad and just select all and paste it now we have this okay so i'm going to make changes inside this one according to our need okay so first thing what i'm going to change is i'm going to change that this one the name for this i'm going to change this one to update details to add new record and after that i'm going to change few properties of this one i'm going to change the top margin so margin top will be now 15 we have to set same for everyone just 15 click on email id it will open that code 15 and in the same image you have to set the margin top 15. now we have to increase the size of these text fields so that these look nice actually so for the edit text field height for this one will be 45 for now and we have to set 45 for everyone every text field actually change this one to 45 and this one also to 4d5 okay now move back over here now we have to add one back button as well because we have changed we have to change this one to ptn add and change this one to save like this and we have to add one more button so i'm going to copy this once again and paste it and change this one to back btn back like this and width will be i'm going to change the width to 200 db on this one height this is height right so width will be 200 dp like this and i don't need this background i need the background tilt and that will be hash ef 6f b5 this is the color that is red or orange little bit and gravity will be center layout gravity is centered and here you can see this we have this in the center and that's fine that's all what we need to start this and let's check if these same scene or not when we click on this when i click on this yeah we have when i click on this nothing happens for now so i'm going to add controls now to these buttons and everything okay so move back over here let me minimize this one now we don't need to actually change the ids for these because this is uh txt name this is txt course this is txt email and this is txt image url this is txt add vdn sorry btn ad and btn back okay so now we have to move back over here to the add activity just double click on this and we move back over here inside this one what we have to do is we have to first register all the edit text and the buttons so for that edit text and first one is name course email and s url after this we have buttons so button ptn add alt and enter and btn back like this and we have to type cast it edit text and we have to search by find view by id r dot id dot and we have set the name txt name like this after this we have course again we have to do the same find your id r.id dot txt course after this we have email edit text find ui id r dot id dot txt email after this we have s url that is student url student image url r dot id dot txt image url like this and we have to register to move that is ptn add and btn back median add dot not dot is equal to this is a button so button and find uid r dot id dot pdn add after this we have one more button that is btn back is equal to button find view by id r dot id dot btn pack when we do something like this we actually create a connection between our code and actual xml file okay so we are referring to this btn ad into the xml file and this will refer back to our this with name we can actually set this name different i just said uh just to identify easily the same one okay you can set this different you can just set it like this back that will be fine it's showing error because we have not declared this variable of back if i delete like this yeah this will work fine okay so not an issue now what we have to do is we have to create a click listener on the both of these buttons so bdn add dot set on click listener new view on click listener this one and one more on the btn back dot sit on click listener new view on click listener and when i click on the back i just want to finish so now let's check if this back button works or not so when i click on this one it actually starts up to our app and that is a base video just to start this and click on back and here you can see this we move back to our recycler view or the dashboard whatever we can say click on this and here you can see this okay so now move back and now we have to code for this one i'm going to add one method so that method will be private and return nothing and i'm going to name this insert data like this and inside this one first thing what i'm going to do is i'm going to fetch the data from all the text field inside this add activity activity add inside this one and save into a variable stored into a variable and then set into a map and then pass that value to the firebase so that the data get inserted okay so first thing i'm going to create a map object so map inside this one first thing will be string and object like this map is equal to new map like not like this this will be new hash map and now we have to put all the values from the text fields so sorry edit text okay so map dot put inside this one we have to pass a name that is name and name dot get text dot and convert that to string in the same way we have to do for others map dot put and this will be course this will be course dot get text dot to string if you are worried that from where i get these name and courses these are nothing but these these names have i'm accessing the value from these edit text right okay so next thing we have is map dot put we have email email dot get text dot to string then map dot put we have s url and we have s u r l dot get text dot 2 string now we the map is ready next thing what we have to do is we have to get the reference of the firebase database for that we have to just write like this firebase database dot get instance dot get reference dot child and inside this child we have to pass this name this one students if you name this something else then you have to pass that value these are auto generated key previously we have typed manually that is s1 s2 s3 and s4 in the previous video in the first video i guess yeah and this time when we insert a new record either we can put this name also or we can auto generate it so this is auto generated that's why it's showing like this okay so we're going to use the auto generated part so students we have to write like this and we have to just call one method that is push and this will simply push the data insert the data by automatically generating a key into the firebase database okay now we have the reference now we have to just set the values at the value and we have to pass the map after this we have to show the user what we actually the data is added successfully or it failed due to some reason like internet issue another issue so we have to add on success listener and inside this one we have to just new on success listener inside this one we have to simply create a toast toast create a new toast and said this one i'm going to write data inserted successfully and after this dot add on failure listener new on failure listener and in this one i want to show some message okay so remove this part and just close this with the semicolon and i'm going to create a toast inside this one we have to show some messes if there is something wrong so error while insertion like this now let's check if this one is working or not and we have to call this method where when we click on this pdn add so insert data that's it just start this and let's check if this one is working or not so click on this move back over here and i'm going to add cherry courses jr is doing mba cherry gmail.com and we have to search one image i'm going to copy this right click copy image url minimize this long press paste minimize this and save data instead of successfully but what i want is when the data is very successfully i want to clear these all fields because this is looking not that much nice to have the previously added data so when i want click on save all data needs to be cleared and we are ready for the fresh data entry if i click on back and here we can see this we have jerry over here and the image is looking and when i click on this yeah this is clear but i want exactly same when i click on this save button for that what we have to do is we have to add one more method that is private void clear all i'm going to just name this method and inside this one we have to clear all the text screen so name dot set text and just set the empty in the same way we have to do for the remaining so set text empty course email dot set text null after this ml we have to set the s url dot set text null and just call this method here whenever we click on this add button after insert data i want to call this clear all method like this if i restart it let's check if this time this is working or not so i'm going to delete this jerry delete yeah delete after this i'm going to write again jerry the course will be mb a cherry gmail.com and i'm going to add the same image which i have previously copied so paste it and just save it this time here you can see the data inserted successfully and all the fields are clear if i click on back now we have this jerry and we can update as well so now this is working so finally we have completed all the card operation we have created updated deleted and we have read the data from the database so that's it for this video guys thanks for watching if you like this video then please hit the like button and subscribe and share with your friends and once again thanks for watching and stay tuned with our channel
Info
Channel: BTech Days
Views: 7,128
Rating: 4.9263802 out of 5
Keywords: retrieve data from firebase to recyclerview, retrieve data from firebase in android recyclerview, firebase recyclerview, how to retrieve data from firebase, firebase, retrieve data from firebase, retrieve data from firebase in android, retrieve data from firebase to listview, firebase database to android recyclerview, firebase data to android recyclerview, get data from firebase to recyclerview, show firebase data to android recyclerview, retrieve data from firebase android studio
Id: SSDwkomJytI
Channel Id: undefined
Length: 123min 16sec (7396 seconds)
Published: Sun May 16 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.