Relative Content

Tag Archive for androidkotlindebugginggoogle-cloud-firestoreencoding

How to retrieve and fetch data from a document’s field on firebasefirestore?

I am trying to fetch data from a document on a firebase’s collection that deos contains users(see image 1)enter image description here.
As you can see, there is a collection named Users and two users, and onw I click on one you get to see the fields and their values. Now, what I need is to retrieve the data within the documents (the fields values) and use it for my app, this is comenthing that ius easily accomplished in Java by using a class variable memmber. However, with Kotlin I can’t do that… so I can’t get the data I want out of the scope of the method addOnColeteListener (I use it like this db.collection().document().get().addOnCompleteListener{ // do stuff to retrieve data }, see code bellow). I realized that I gave more code that needed, but i wanted to add more context just jump right to the setUserIfno()