Skip to content

Instantly share code, notes, and snippets.

@imrankst1221
Created May 13, 2019 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imrankst1221/f2e9f5cdbb6f1a1452f0859301acd7a0 to your computer and use it in GitHub Desktop.
Save imrankst1221/f2e9f5cdbb6f1a1452f0859301acd7a0 to your computer and use it in GitHub Desktop.
Write Data Object On Firestore
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) }
}
@callebdev
Copy link

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 be student["age"] = studentItem.age.
Leaving that, I really liked the article, and I hope you continue to write more articles.

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