‫Let's read the custom objects from Firebase.
‫I will create a val post event.
‫Equal an object.
‫And value event.
‫Listener and this value event listener is similar to what we've done before.
‫I will click here and alt+ enter to implement the members.
‫You can see these are two methods that we need to implement on data change and on cancel the.
‫Here.
‫We need to get the data as snapshots.
‫So we've talked about it in the previous video that all the data in Firebase is get it as new, new
‫form or new objects called data snapshots.
‫Okay.
‫So to receive data from A and get the data from Firebase, we need to deal with data snapshots.
‫I will create user.
‫I'm receiving data in form of user that we've created before.
‫This is the data class.
‫I will create an object called u one.
‫Equal to data snapshot or snapshot.
‫Sorry, Val.
‫You won.
‫Its type as user equal to snapshot dot.
‫Here.
‫We need to get the value or the value of.
‫Dot value of get value.
‫And here we need to pass the.
‫Get value, not value.
‫I'm getting the value and you need to specify the value type.
‫Here you need to pass.
‫The type parameter is of type user.
‫Okay, you can remove this.
‫And here we are specifying the user.
‫Okay.
‫Import.
‫I'm importing the user.
‫And everything is working fine.
‫Now let me display this user.
‫So.
‫The text.
‫The view here.
‫Van Text View.
‫It's of type text view.
‫Equal to find view by ID or id dot text view.
‫I will set this text view dot text equal to u 1.2 string.
‫Let me run the application and see the.
‫Username and password.
‫Let me check for.
‫Okay.
‫I have missed that this event value event listener is not added to the reference, so don't miss to
‫add the database.
‫Dot.
‫Add value event Listener P.
‫Let me run the program again.
‫And here we go.
‫We have an error.
‫Why?
‫If we open the logcat, we can see that the main activity.
‫I need to add the value event listener.
‫Okay to a specific child because I am not specifying a specific child here.
‫I need to use and specify the child users and you can see guys, it's users and it's case sensitive.
‫So users.
‫Let me run again.
‫If we open the lookout, we can see that Firebase user doesn't define a no argument constructor.
‫So this is happened because I need to initialize these values like this.
‫And like this.
‫So whenever you use Firebase.
‫With custom objects and data classes.
‫Please initialize this variables.
‫If I run the program now, it will give me the user username equal jack and password equal to one,
‫two, three.
‫So congratulations guys.
‫We've added the event and the value event listener correctly to this application and we redid the custom
‫objects from Firebase.