I have a form and wish to save it when the save button is pressed, the solution I did is not working.
public class SalvarFormulario extends AppCompatActivity {
EditText Nome;
EditText edtTelefone;
EditText edtObservacao;
EditText edtEmail;
Button btSalvar;
FirebaseDatabase firebaseDatabase;
DatabaseReference databaseReference;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_formulario);
Nome = (EditText) findViewById(R.id.Nome);
edtEmail = (EditText) findViewById(R.id.edtEmail);
edtObservacao = (EditText) findViewById(R.id.edtObservacao);
edtTelefone = (EditText) findViewById(R.id.edtTelefone);
btSalvar = (Button) findViewById(R.id.btSalvar);
InicializaFirebase();
SalvarDados(); // <--- salva os dados
}
private void InicializaFirebase() {
FirebaseApp.initializeApp(SalvarFormulario.this);
firebaseDatabase = FirebaseDatabase.getInstance();
databaseReference = firebaseDatabase.getReference();
}
private void limparCampos() {
Nome.setText("");
edtTelefone.setText("");
edtObservacao.setText("");
edtEmail.setText("");
}