Reputation: 1521
I am fetching a list of DocumentReference
which I am fetching from firestore. It looks like this:
com.google.firebase.firestore.DocumentReference@4a69111d
However, I can't get the object using the above in the following code.
var loc = com.google.firebase.firestore.DocumentReference@4a69111d
var documentRef:DocumentReference = firestore.document(loc.toString())
documentRef.get().addOnSuccessListener { document ->
if (document != null) {
Log.d("SHARED_PREF_VM", "DocumentSnapshot data: ${document.data}")
}
})
Can I somehow convert com.google.firebase.firestore.DocumentReference@4a69111d
to this form /cities/blr/areas/alpaca
Upvotes: 0
Views: 2217
Reputation: 317712
That string is just the generic Java/JVM representation of an object when its implementation does not override toString()
. It is mostly meaningless and useless to an application.
If you want to convert a DocumentReference to a string in order to use later as a DocumenReference, you should use the getPath() method on it. That will return a string which uniquely identifies that document. Then, you can turn that string back into a DocumentReference with firestore.document(), which.
Upvotes: 3