Integrate Firebase Realtime Database to Android App

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys welcome back to another Android firebase tutorials today we are going to learn about how to implement fireplace real time database in your Android application so when we hear the tape database the first thing that comes to our mind is table rows columns primary key secondary key excellent but any of these components are not available in firebase real time database instead in firebase real time database behind working with JavaScript object notation of symbolic code Jason so the firebase real time database is a data entry here is a simple firebase real time database entry so this is a Jason tree here the routine or discharge that contains two tile denotes message 1 and Method 2 so in firebase real time database the data is represented using each node in adjacently so if you want to insert data to a fireplace a real time database that means you have to add a new node to the firebase jason-3 if you want to delete a particular data from the firebase real time database that means you need to delete you need to remove a node from these Jason tree so if you want to update the message that means if you want to update the name on message 1 in that case first one you how to access the parent node here the parent node is stirred and by using that instance you can access the tile denote then you can update the database so this is a simple firebase real time data representation so in this video I am going to show you what are the basic steps you must follow to implement fireplace real time database in your Android application so here we need to project first of all is an Android studio project and second one is the project in firebase console so now we can start with a new and to do project open-angle studio and start a new Android studio project this is why your application name okay here the project is created first we can add firebase to this Android studio project so open manifest folder open androidmanifest.xml first here i am going to add the internal permission for the application now copy the application package name now open your browser and go to firebase console here you can create a new project or you can select an existing project here I have an existing project now add firebase to your Android app here specify the package name and here we got the Jason configuration file copy the JSON configuration file now change this one into project view now you need to place the configuration file within the app folder okay now here the configuration file available within the app folder now change this one into Android now we need to add some dependencies and plugins click continue now copy this line copy this plugin now go to the Gradle section open project level Garry's file and add the lines here now copy this plug-in copy this line now open module level grease file add the line to the bottom of this file now we need to add the dependency for using firebase a real-time database and click finish now go to the document documentation section select Android section yes here is the dependency on firebase so we have to use the real-time database for copy this line now add the needed dependency you might you have to add it inside the module level queries file okay now here we add all the needed dependencies on plugins now make the project swing okay now the processing finishes go to activity main.xml here we already have a text review and delete that text TV now add a new text review to this layout change ID of this text review make it in the ball we need a larger text review okay now go to main activity dot Java create some variables for textview now initialize that variable it is a textview now find it okay now we can use this textview for display the data from the firebase a real-time database so for accessing the firebase real-time database first thing you have to create you how to get an instance of the firebase database so here see it available for catering instance of firebase database for a base database dot get instance okay now we need to access the route the node of the adjacent lead I already tell you in firebase real-time database data is saved in the form of adjacently so for working with the database first we have to get an instance to the route the node of the adjacently so for that create available database a reference in emitters M wrote the reference by using the firebase instance firebase database don't get elephants so this will this will provide this statement will provide a reference to the route to node of the firebase retain database now we can access the child nodes so for that create another variable database reference M child reference by using the routine node we can access the child ma Rotella French dot child and here you have to specify the route ID that means the child I leave here I specify that one in two message okay so we have to display the data on the textview so this is a real-time database that means we have to display any change on the database in a real-time to this such TV for that we have to specify some some listeners so here I'm going to overwrite one more life cycle method on start from that mother Here I am going to specify a listener for the database reference so here we have to get the we have to get any data change on this trend not called message so here the method references M child the reference so we have to specify some listener for that della parent how to use a listener called the set sorry not add value e value even listener this is the listener add value even listener so here we got two methods or data change and on cancel so if there is any change on the data available on the real-time database this method will invoke so if the user is not obligated or there is an error occurred in such situation the on cancel the method will invoke so we got the real-time data changes within this method called on data change here we go to an object of data snapshot that object contains all the needed methods and data so here we can get the data from the data that snapshot is equal to data captured dot you can use a method called the get value and here you have to pass the type here is a string value okay now we can display the data on the text view so message text or text message okay so now the application is ready now we can run it on a virtual device so now I'm going to start a virtual device so before going to run these applications set some default message on the text let's give you the state of T up here okay now the first row device is ready now we can run the application so I'll run it okay now the application available on this virtual device now we can go to firebase control and set up our database so go to firebase console from website you can access the database section so by default only authenticated users can access the database so if you want to provide public access to the database you have to change the database rule so go to the rules section by default the read and write operation on any firebase database is reflected to the only authenticated users so here there is no reason right operation function for any unauthorized users so in the case of a real Android application you have to specify some authentication rules otherwise your database can access anyone so be careful while declaring the authentication rule so now here I'm going to make this database available for the public so I change the read operation in the truth also here I provide a write permission to anyone and publish the rule now go to the data section so now we can create the database so here we have some information here this is the rupee note of be decently now we can create a title the note so click the plus symbol now here specify the ID for this I'll denote I named it a message specify a value for it and click the Add button so here we are a child in ode to the routine note but that data is not available on the virtual device you have to restart the application before because we changed our database rules we have to restart the app and here is the data now the data available on our application so now this is the dayson tree that contains a routine owned and child in owed the child is not contained our data so now I'm going to modify the data good morning plug ish and click the Add button and here you can see that in real time the data available on our line Chloe's virtual device so this is how we working with a fireplace a real-time database and click the Add button now the data available in real time on the app so this is these are the basic steps you must follow to implement firebase a real time database in your Android studio project so this is a basic example from the next video onwards we are going to learn more about how to working with firebase in real time database I hope you understand all these concepts please subscribe to this channel now for getting more firebase video updates thank you for watching see you in the next episode
Info
Channel: PRABEESH R K
Views: 44,136
Rating: undefined out of 5
Keywords: android firebase realtime database, firebase, database, firebase realtime database, firebase android tutorial, training, android studio, fcm, android database, realtime database, android studio tutorial, prabeesh r k android
Id: QETnC6SEwa0
Channel Id: undefined
Length: 16min 8sec (968 seconds)
Published: Tue Jan 31 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.