Get data from the database in this way, Firebase Android

0

How do I obtain this data that is marked in this example, in a list.

Try this code, but nothing.

String cuswtId = String.valueOf (FirebaseDatabase.getInstance (). getReference (). child ("Users"). child ("Customers")

Any way?

    
asked by Anderson Jamanca 01.04.2018 в 23:13
source

1 answer

0

What you need are the keys of the nodes, with this code you would read all the nodes that hang from customers, and from those nodes you'll keep the keys.

DatabaseReference myRef = FirebaseDatabase.getInstance().getReference().child("Users").child("Customers");
ValueEventListener eventListener = new ValueEventListener() {
    @Override
    public void onDataChange(DataSnapshot dataSnapshot) {
        for(DataSnapshot nodo : dataSnapshot.getChildren()) {
            String key = nodo.getKey(); //estos son los valores que buscas
            Log.d("TAG", key);
        }
    }

    @Override
    public void onCancelled(DatabaseError databaseError) {}
};
myRef.addListenerForSingleValueEvent(eventListener);
    
answered by 02.04.2018 / 00:34
source