Well, assuming you’ve already created your Alert or know how to create it because you haven’t posted any code, you can do the following:
Assuming the user enters some data in edits, and Alert has a Positive button that will save this information and a model class that will work this data, you will call the model class, which in this example is a user class.
In the Model class, in addition to the variables and the getters and setters you will have this method:
public void salvar(){
DatabaseReference banco = FirebaseDatabase.getInstance().getReference();
banco.child("USUARIOS").push().setValue(this);
}
Now it is enough that you in the positiveButton method of Alert create the following call:
Usuarios usuarios = new Usuarios();
usuarios.setNome(editNome.getText().toString());
usuarios.setEmail(editEmail.getText().toString());
usuarios.setTelefone(editTelefone.getText().toString());
usuarios.salvar();
dismiss();//para fechar o alert
Or you can do this update without the model class, sending data when it is clicked on the positive Alert button in this way:
DatabaseReference banco = FirebaseDatabase.getInstance().getReference();
banco.child("USUARIOS").push().setValue("nome", etNome.getText().toString())
.setValue("email", etEmail.getText().toString());
The two options should work, there is your creitério although I recommend using the model classes to make the work better organized.
Any doubt I’m available!
Eder, you’ve saved data in firebase before, if so, how does ? use a model class for this ?
– Eduardo Rafael Moraes
Opa Eduardo, yes I’ve saved in other projects but it was simple things
– Eder Rodrigo Coffani