Skip to content

Instantly share code, notes, and snippets.

@imrankst1221
Last active May 21, 2021 15:27
Show Gist options
  • Save imrankst1221/18498e287781513381999516e56f68a5 to your computer and use it in GitHub Desktop.
Save imrankst1221/18498e287781513381999516e56f68a5 to your computer and use it in GitHub Desktop.
Read Data From Firestore
private fun readDataFromFirestore(){
mFirestore = FirebaseFirestore.getInstance()
mFirestore.firestoreSettings = FirebaseFirestoreSettings.Builder().build()
mFirestore
.collection("student_info").document("student_list")
.get()
.addOnSuccessListener { document ->
try {
if (document != null) {
studentInfo = document.toObject(StudentInfo::class.java) ?: StudentInfo()
initListView()
Toast.makeText(mContext, "DocumentSnapshot read successfully!", Toast.LENGTH_LONG).show()
} else {
Toast.makeText(mContext, "No such document!", Toast.LENGTH_LONG).show()
}
}catch (ex: Exception){
Log.e(TAG, ex.message)
}
}.addOnFailureListener {
e -> Log.e(TAG, "Error writing document", e)
}
}
@dinakardhanush
Copy link

what is initlistview()?
can you add initlistview code..?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment