‫Hello, my friends, and welcome back.
‫One can ask how to receive and get all documents in the collection or how to get multiple documents
‫from a collection.
‫The answer is very simple.
‫Since we are dealing with Firebase and Firestore and the product of Firebase, we can expect that the
‫codes are minimalized and things are very simple to do this like kinds of queries.
‫So this is how we get.
‫Getting.
‫A specific data from collection or from document.
‫How to get.
‫All documents in the collection.
‫Getting all documents.
‫From collection.
‫Okay.
‫We start by DB dot collection.
‫I'm getting the collection.
‫I will.
‫I will comment this.
‫Collection.
‫What is the name of the collection?
‫It's called Users.
‫You can see.
‫Dot.
‫Get.
‫You can see.
‫Get.
‫It's a queer.
‫It returns a task of query snapshot.
‫So get.
‫Dot.
‫And Onsuccess Listener What we need to add in success.
‫Listener We need to use result.
‫I will make it as a.
‫The.
‫Lambda expression for every document.
‫In result.
‫Go and display from this document the names, or you can display all the data.
‫So for example, text view, dot text equal to I need to get all the documents and all the data inside
‫the documents.
‫So it's very simple.
‫I can specify here.
‫Document.
‫Dot.
‫Date.
‫It's a mutable live data.
‫Let's run the program again.
‫You can see.
‫That I'm getting only the one.
‫The first one.
‫Let me go up and check here.
‫I will.
‫Command this.
‫Also.
‫Let me run again.
‫So you can see that we are getting only one one item here and only one document.
‫Let me check if there from the layout or from the text view is the error or from my coding log I tag
‫and I will receive all the documents inside this tag.
‫Here.
‫Okay.
‫I will commend this text to view and let me run the application.
‫And if I go to Logcat, you can see, guys, that this is my old documents inside the collection.
‫Last name, Richard Bourne and the name.
‫And here, the second.
‫Uh, the second collection.
‫The second document is so.
‫Here we have.
‫Correctly getting the data from the from the text from the Firestore into the logcat.
‫So here the error is that every time the loop is doing iteration, I am replacing the text view with
‫the new data.
‫So for that I will remove this text view, I will paste it here and I will create a string object here.
‫Getting all objects, Val.
‫All documents.
‫Equal to or it's of type string and equal to.
‫These empty strings.
‫I will add every and every iteration.
‫I will add all documents, Dot.
‫Equal to append.
‫Equal to.
‫The new document Data Document Dot data.
‫Okay.
‫And I will change it to var.
‫Okay, then I need to display.
‫The old documents.
‫Let's run our application.
‫And you can see.
‫The errors still persist because I missed here to add the plus sign.
‫Let me run again.
‫And here we go.
‫We are fetching all the documents.
‫So congratulations, guys.
‫We have succeeded in getting all the documents from the collection you can use like this.
‫And for for separating the collections to New Line.
‫Every.
‫Or this will not work.
‫I will add all documents plus, and I'm appending here to the strings.
‫Of Scotland.
‫Of Scotland Strings.
‫The new Line.
‫And waiting.
‫For that change here.
‫I will add like this.
‫Let me run again.
‫And here we go.
‫You can see this is the first document and this is the second document and all the data inside and the.