How to Retrieve Data From Firestore with Kotlin ?
Google Firestore Provides No SQL database where we can keep data and it is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud Platform.
For more about Google Firestore you can visit on bellow the link https://firebase.google.com/docs/firestore?authuser=0
Your project should be added in your Firebase Project
Add dependencies directly Open your project in android studio Tools>Firebase > Firestore> click on Add Dependencies
MainActivity.kt
var firestore: FirebaseFirestore
firestore = FirebaseFirestore.getInstance()
firestore.collection("users")
.get()
.addOnSuccessListener {
Toast.makeText(this, "Your first name is ${it.documents.get(0).data?.get("first_name") } and last name is ${it.documents.get(0).data?.get("last_name") }", Toast.LENGTH_SHORT).show()
}
.addOnFailureListener{
it.printStackTrace()
Toast.makeText(this, "Failed", Toast.LENGTH_SHORT).show()
}
}
That’s all , Thank you for reading my article
you can see my project on GitLab
https://gitlab.com/sudishkumar/retrieve-data-from-firebase-kotlin