Here is the code
val db = Firebase.firestore
val user = hashMapOf(
"name" = "{binding.edit_name.text.toString()}",
"email" = "{binding.edit_email.text.toString()}
)
binding.submitBtn.setOnClickListener{
db.collection("users").add(user)
.addOnSuccessListener {
Toast.makeText(context,"Data inserted",Toast.LENGTH_LONG).show()
}
.addOnFailureListener {
Toast.makeText(context,"Error",Toast.LENGTH_LONG).show()
}
}
In above code edit_name , edit_text is input taken by keyboard. I can't able to store the user in firestore. I think there is problem of converting bindig.edit_name.text.toString() it can't able to convert string. If i use hash map without taking input from keyboard as below then I am able to insert data in firestore.
val user = hashMapOf(
"name" to "ABC",
"email" to "abc@gmail.com"
)
This hash map is able to add in firestore.
I think there is problem in binding and I am also can't able to toast bindg.edit_name.toString() as shown below
binding.submitBtn.setOnClickListener{
Toast.makeText(context,"${binding.edit_name.text.toString()},Toast.LENGTH_LONG).show()
}
Please help in this. I think all problem is that I can't able to convert binding data value as a string (by default it is Editable).