‫Hello, my friends, and welcome back.
‫In this video, we're going to receive the data and receive the collections and documents from the Firestore.
‫So I will initialize this text view.
‫Val Text view type.
‫Text view equal to find view by ID.
‫Text view.
‫And our.id dot text.
‫Alt+ enter.
‫Let me go to the activity and this is the text view.
‫One.
‫Now I will update the text view with the received data.
‫So I will go to here I will receive.
‫Data or documents.
‫From Firestore.
‫How to receive.
‫I will create Val.
‫Document reference.
‫I will make a document reference I need to get, for example.
‫User one.
‫I don't need user to, I need user one.
‫So I will create val document reference db dot collection.
‫What is the name of the collection?
‫It's called Users.
‫You can see it's the name here Users.
‫Okay, users.
‫This is the name of the collection.
‫Users.
‫Yes.
‫Dot Document.
‫What is the name of the document?
‫It's called User one.
‫You can see I need to get user one now.
‫I will set document dot.
‫Document.
‫RAF.
‫Dot get and this get you can see that get is is.
‫Returning a task of document, document snapshot.
‫So I will add it.
‫Dot Add on success Listener.
‫This add on success.
‫Listener I will use document.
‫Here.
‫This is the document.
‫And you can set it like this.
‫If.
‫Document does not equal to null.
‫So there is data inside it.
‫We need to display it in the text view.
‫So text view dot text equal to document how to get the data from the document.
‫I will get it like this.
‫Here.
‫Document dot data.
‫This is a mutable map of type string.
‫Data.
‫Okay.
‫This is how we get the data from the Firestore using the document document variable.
‫Okay.
‫You can see in the previous Firestore Firebase realtime databases we've used the document data snapshots.
‫Okay.
‫Now you can add more listeners like on Canceled on Failure and so on.
‫Let's run the application and see how to get the data from Firebase Firestore.
‫You can see, guys that it's changed instantaneously because we've got the data here from User one.
‫Born 1992.
‫Last name Richard Last name.
‫And the first name is Jack.
‫I can set like this dot data dot get.
‫What is the key?
‫I need only the name, so I need to specify here the name.
‫I.
‫Need to add this exclamation this question mark in order to set it to null.
‫And you can see, guys, that the first document and the first user inside the users collection, its
‫name is called Jack.
‫I can get and by the way, it's case sensitive.
‫I need to get like for example, born.
‫So I put here born.
‫I will run the program again.
‫And you can see 1992, I'm getting the Bourne value.
‫This is the key.
‫Bourne and the value 1992 from the document, which is the user one from the collections users.
‫So congratulations, guys.
‫We've learned how to get the data from documents and deal with documents and collections.
‫The received data from Firestore.