Retrieve snapshot within a node

0

I need to recover all users within a user node, following firebase structure:

FormetoretrievethesevaluesI'mmakinganaddListenerForSingleValueEvent,followscode:

privateDatabaseReferencefirebaseRef;privateDataSnapshotusuariosSnapshot;firebaseRef=ConfiguracaoFirebase.getFirebase();//recuperarusuariosparacriaçãodofeednahoradapostagemDatabaseReferenceusuariosRef=firebaseRef.child("usuarios");
                usuariosRef.addListenerForSingleValueEvent(new ValueEventListener() {
                    @Override
                    public void onDataChange(DataSnapshot dataSnapshot) {

                        usuariosSnapshot = dataSnapshot;

                    }

                    @Override
                    public void onCancelled(DatabaseError databaseError) {

                    }
                });

                postagemPendente.salvar(usuariosSnapshot);

Even if the reference is pointing to the right place, the userSnapshot still shows as null, what do I have to do to get all those values from within the users node?

Note: This is all within an Adapter, which I think is irrelevant but by way of doubt.

    
asked by anonymous 07.12.2018 / 12:58

1 answer

0

Try instead of DatabaseReference usuariosRef = firebaseRef.child("usuarios"); add .getReference().

The getReference () gets the root node of the database. More information here .

So it would be DatabaseReference usuariosRef = firebaseRef.getReference().child("usuarios");

    
07.12.2018 / 13:10