0
I would like to know how I can add a new node inside my Child 88d4c350-d2db-4765-b7da-0652b1278bd7 that is inside Child ETE, without overwriting the two tests?
public void salvar(){
try {
if (idButtom == R.id.btn_im_cx_gord) {
Ete ete = new Ete();
ete.setCaixaDeGorduraExistente(spn_st_cx_gordura.getSelectedItem().toString());
ete.setProjetoCxGord(spn_projeto_sub.getSelectedItem().toString());
databaseReference = FirebaseDatabase.getInstance().getReference().child("MANUTENÇÃO");
databaseReference.child(id).setValue(ete);
}
databaseReference.child("MANUTENÇÃO").child(id).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
Intent intent = getIntent();
String id = intent.getStringExtra(MainActivity.Uid);
Ete ete = dataSnapshot.getValue(Ete.class);
if (ete != null) {
ete.setModeloGrad(spn_mod_grad.getSelectedItem().toString());
ete.setSituacaoGrad(spn_st_grad.getSelectedItem().toString());
ete.setPresenGordGrad(spn_pres_gordura_grad.getSelectedItem().toString());
ete.setResProcProdut(spn_res_pros_prod_grad.getSelectedItem().toString());
firebaseDatabase.getReference("MANUTENÇÃO").child(id).setValue(ete).toString();
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
} catch (Exception ex){
MensageBox.Show(this, "Erro", "Erro ao Salvar Dados" + ex.getMessage());
}
}
I migrated to Firestore as soon as possible, because the Realtime Database has some disadvantages, the main one is that there is no document storage, but the storage of a single gigantic document, anyway there is a method for this updateChildren() instead of setValue() take a look at doc https://firebase.google.com/docs/database/android/read-and-write?hl=pt-br
– Rodolfo Patane