‫Hello, my friends, and welcome back.
‫In the previous videos, we learned how to write data to Firebase and how to read data from Firebase
‫Realtime Database.
‫In this video we will learn how to read and write data from Firebase, but this time is the custom objects.
‫So if we go back to the price and the key value pairs the price and the value, this is a primitive
‫or a string, or the simple values, you can consider them as simple values.
‫What about objects?
‫So we're going to learn how to write objects, how to receive objects from Firebase Real Time database.
‫So I will comment this and.
‫Here, I will create a new Java.
‫Day or sorry, New Kotlin class.
‫Data class and I will name it as user.
‫Click enter and this data class will have two parameters in the constructor.
‫The first one is Val or the user name.
‫User name.
‫It's of type string.
‫And the password, Val.
‫Password is of type string.
‫Okay, so I'm going to save.
‫In the Firebase databases.
‫The value of these objects, the variables, these objects of type user.
‫Let me go to here to the main activity.
‫I will remove this and I will start as usual when dealing with databases.
‫We start with the reference.
‫So I'm getting the same reference.
‫So here I will remove the comments.
‫And this is the reference to our database.
‫I have created this database reference variable and here how we get the real time database from where
‫database or this Android application knows the database and the reference.
‫It's exactly from the Google services dot Json file that we have added to our project.
‫Okay.
‫Now writing
‫writing custom objects to Firebase, I will create Val user one.
‫It's of type user equal to user.
‫And I will open the.
‫Parentheses and I will specify the username is Jack and the password is one, two, three.
‫Okay.
‫How to save this object to Firebase.
‫It's the same as before.
‫Data base dot child.
‫I can specify here the child I will name the child as users and dot set value to user one.
‫Let me run the application and see the real time database.
‫Here we go.
‫We have created a new node, a new child called users.
‫The this users will contain that child, that user, one that have or that has the username Jack and
‫the password.
‫One, two, three.
‫Okay, so congratulations guys.
‫We have saved a custom object on real time database.