I have a structure in the firebase as follows. In the client app when the person saves the information, creates a child stored by the number entered in the cell field (creates the child with the person's cell number). If another person uses the app, when that other person saves (creates another child with that new number that was placed in the cell field). Then we have two childs of different numbers.
How can I retrieve these values in my admin app, since the child will be dynamic.
ThiscodebelowiswhereIretrievetheinformationanddisplayinaListview.IfIputsodatabaseReference.child("Pedidos").child("(99)99999-9999")
it searches the bank and brings information from that number, so far so good, it's working. But I'm putting it manually.
databaseReference.child("Pedidos").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Pedido pd = new Pedido();
listPedidosAdm.clear();
for (DataSnapshot objSnapshot : dataSnapshot.getChildren()) {
pd = objSnapshot.getValue(Pedido.class);
listPedidosAdm.add(pd);
}
if (listPedidosAdm.size() <= 0) {
Toast.makeText(AdmPedidosActivity.this, "Não há nenhum pedido",
Toast.LENGTH_SHORT).show();
} else {
AdapterPersonalizadoAdm adapter = new AdapterPersonalizadoAdm(listPedidosAdm,
AdmPedidosActivity.this);
listview_AdmPedidos.setAdapter(adapter);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}