How to Insert Data in Firebase Realtime Database | Android Firebase Part 3

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys welcome to soft coding in this video i'm going to show you how to insert data in firebase real-time database and last video we have created and connected our firebase real-time database with our android project if you haven't seen my last video so don't worry the link is in description in this video we will insert data in firebase real-time database but before that you have to change these two rules by default the read and write rules are files so you have to change it to true before inserting or retrieving data from firebase real-time database so now let's open up our android project okay let's suppose we are inserting a student record in our database so for that we we will need some fields i will do i will define some required fields here really quick so you so here you can see our left is ready now open your main activity.java and here we need to specify variables for that views and make a reference to that views so let's do it now we will need a database reference to access our database and insert our data so for that database reference we will name it student dv and here in oncreate student is equal to firebase database not get instant start get reference that child will give it a name students you can give it any name you want you can consider it your database name so i will give it a student now we will insert our data when the insert data button is clicked so here we will set a click listener on or button on location insert student data now create this method here so now we will get a user input and store it in some variables like name is equal to et calls get selected item stream now we will define a model class or student data so name it students we will define three variables here so name create constructor and press ctrl and select all these click ok constructor is created now we will need to create getters for this generator and do the same select all click ok now we will create a student class objection and pass the data we are getting from input fields dot push as you can see dark side value is accepting only object so we will pass the students object to set values it will insert all data in firebase database we will pass a student here okay so we are using here uh that push method we are using this method to generate a unique id or a unique key for every new record if we are not using this in our insertion process so the data will be overrated on previous records so the new record will be not inserted uh our the new record will be inserted but the previous one will be overrided with that so we are using dot push to generate a unique id in when every when new record is inserted we will show a toast here data inserted now let's run okay you can see the app is launched we will pass some data here so as you can see we pass a child named student so here is a student's node and here is our data inserted this is the unique key this key is generated by dark push method so if we insert a new record here we'll change the name to comrade and cause to u2 it will be 14. and click on insert so as you can see the new record is inserted here with name camera or number 14 and course is so this is how you can insert data in firebase real-time database and this will be the structure of your firebase database so that's it for today and in next video i will show you how to retrieve data from firebase serial
Info
Channel: CodingZest
Views: 72,251
Rating: undefined out of 5
Keywords: SoftCoding, how to insert data in firebase database android, inserting data in firebase realtime database, how to insert data into firebase real time database in android, insert data in firebase realtime database, android firebase tutorial, firebase realtime database android tutorial, firebase tutorial, firebase realtime database, insert data in to firebase database, insert data in firebase android, android firebase database, codinginflow, educatree firebase, simplified coding
Id: 9JdbgoYgCyA
Channel Id: undefined
Length: 9min 52sec (592 seconds)
Published: Mon Jul 27 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.