Created
May 13, 2019 07:55
-
-
Save imrankst1221/f2e9f5cdbb6f1a1452f0859301acd7a0 to your computer and use it in GitHub Desktop.
Write Data Object On Firestore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun writeDataOnFirestore(studentItem: StudentItem){ | |
val student = HashMap<String, Any>() | |
student["name"] = studentItem.name | |
student["age"] = studentItem.name | |
student["address"] = studentItem.address | |
student["mobile_no"] = studentItem.mobile_no | |
mFirestore.collection("student_info").document("student_list") | |
.set(student) | |
.addOnSuccessListener { Log.d(TAG, "DocumentSnapshot successfully written!") } | |
.addOnFailureListener { e -> Log.w(TAG, "Error writing document", e) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I was reading your article about Cloud Firestore on Medium.
I found the article very clear, explanatory and awesome.
I noticed an error in the fourth line of this piece of code.
Instead of
student["age"] = studentItem.name
it should bestudent["age"] = studentItem.age
.Leaving that, I really liked the article, and I hope you continue to write more articles.