'Add a value to a Firebase field [closed]
I want a field of a database that I have in realtime firebase to be updated, that is, the amounts that I pass to it are added to it. My problem is that it never gets updated, it only overwrites it by deleting the previous data and putting the new one. This is the part of my code that gives me this problem:
val correo = FirebaseAuth.getInstance().currentUser!!.email
bdUsuario = bd.child(FirebaseAuth.getInstance().currentUser!!.uid)
var valor = 0
val usuario = FirebaseAuth.getInstance().currentUser!!.uid
bd.child(usuario).child("Puntuacion").get().addOnSuccessListener {
valor = it.getValue() as Long
}
bdUsuario.child("Usuario").setValue(correo)
bdUsuario.child("Puntuacion").setValue(valor + respuestasIncorrectas)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
