I want to get data from the cloud firestore and have to store it to a string variable but unable to do so and need help.
This is below code
val db = FirebaseFirestore.getInstance()
val docRef = db.collection("SlideShowImages").document("1")
docRef.get()
.addOnSuccessListener { document ->
if (document != null) {
Log.d(TAG, "DocumentSnapshot data: ${document.data}")
} else {
Log.d(TAG, "No such document")
}
}
.addOnFailureListener { exception ->
Log.d(TAG, "get failed with ", exception)
}
getting this from database and I want Link to store to variable first_image
{about=FCB, link=https://firebasestorage.googleapis.com/v0/b/missionx-g6305.appspot.com/o/EVENTS%2FSlide%20Show%20Images%2FCurrent%2FFCB.jpg?alt=media&token=950c5200-c553-4639-b33e-2b91a220b19c}
And I want to store it in variable
val first_image : String
first_image = document.data.link
when I use this I am getting an error