0
I’m using this structure to save the data:
private void salvar() {
Protocolo protocolo = new Protocolo();
protocolo.setAssunto(edtAssunto.getText().toString());
protocolo.setnProtocolo(edtNProtocolo.getText().toString());
protocolo.setNomeEmpresa(edtNomeEmpresa.getText().toString());
databaseReference.child(user.getUid()).child("Protocolos").child(protocolo
.getNomeEmpresa()).child(protocolo.getAssunto()).setValue(protocolo);
limparCampos();
}
but when it comes to bringing in the data from Firebase
, I cannot use the correct structure to bring the user id, then the "protocol" node, then the company, then the subject with your information. I’m using this structure to bring you information from Firebase
, and with it mine Listview
displays nothing:
private void inicia() {
inicializaFirebase();
final ListView listView = (ListView) findViewById(R.id.lista_protocolos);
final List<Protocolo> listaProtocolo = new ArrayList<>();
databaseReference.child(user.getUid()).child("Protocolos").child("aqui preciso por a empresa")
.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot objSnapshot : dataSnapshot.getChildren()) {
Protocolo protocolos = objSnapshot.getValue(Protocolo.class);
listaProtocolo.add(protocolos);
ArrayAdapter<Protocolo> adapter = new ArrayAdapter<>
(ProtocolosActivity.this, android.R.layout.simple_list_item_1, listaProtocolo);
listView.setAdapter(adapter);
}
if (listaProtocolo.size() < 1) {
alert("Você ainda não tem nenhum protocolo cadastrado");
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
what should I do?
Why are you using setValue(protocol)?
– porthfind
Protocolo
is my instance. ai osetValue
is saving my objectprotocolo
given in theFirebase
– Fabio Souza
You have to go in pieces or it’s complicated. First: before doing this: listProtocolo.add(protocols); can you print out any protocol data? Or not?. Second: the datareference you are setting reaches where? You can print with Log. d and debug to see how far you can get in the Firebase structure.
– porthfind
You can show the class
Protocolo
?– Rosário Pereira Fernandes