Get values from the 4th node of Firebase on Android

1

I need to look for the red-highlighted values in the image, but I only know the item in blue.

Itriedthisway:

firebase=ConfiguracaoFirebase.getFirebase().child("tb_contato").child(identificador);
                valueEventListener = new ValueEventListener() {
                    @Override
                    public void onDataChange(DataSnapshot dataSnapshot) {
                        for (DataSnapshot filho: dataSnapshot.getChildren())
                        {
                            Contato contato = filho.getValue(Contato.class);
                            Log.i("Teste","Teste");
                        }
                    }

                    @Override
                    public void onCancelled(DatabaseError databaseError) {

                    }
                };
                firebase.addListenerForSingleValueEvent(valueEventListener);

Where "identifier" is the blue italic value of the image.

But when trying to compile, it returns me like this:

    
asked by anonymous 03.08.2018 / 21:01

1 answer

0

I solved it this way, I do not know if it is the most appropriate, but it worked.

firebase = ConfiguracaoFirebase.getFirebase().child("tb_contato").child(identificador);
                valueEventListener = new ValueEventListener() {
                    @Override
                    public void onDataChange(DataSnapshot dataSnapshot) {
                        if (dataSnapshot.exists()) {
                            for (DataSnapshot filho: dataSnapshot.getChildren())
                            {
                                chaveServico = filho.getKey();
                                firebaseContato = ConfiguracaoFirebase.getFirebase().child("tb_contato").child(identificador).child(chaveServico);
                                valueEventListenerContato = new ValueEventListener() {
                                    @Override
                                    public void onDataChange(DataSnapshot dataSnapshot) {
                                        for (DataSnapshot filho: dataSnapshot.getChildren())
                                        {
                                            //===== Altera o nome do usuário no contato =======
                                            String chaveUsuario = filho.getKey();
                                            firebaseUsuario = ConfiguracaoFirebase.getFirebase();
                                            DatabaseReference hopperRef2 = firebaseUsuario.child("tb_contato").child(identificador).child(chaveServico).child(chaveUsuario);
                                            Map<String, Object> hopperUpdates2 = new HashMap<>();
                                            hopperUpdates2.put("cttUsrIDNomeSolicitante", txtNome.getText().toString());
                                            hopperRef2.updateChildren(hopperUpdates2);

                                            firebaseUsuario = ConfiguracaoFirebase.getFirebase();
                                            DatabaseReference hopperRef3 = firebaseUsuario.child("tb_contato").child(chaveUsuario).child(chaveServico).child(identificador);
                                            Map<String, Object> hopperUpdates3 = new HashMap<>();
                                            hopperUpdates3.put("cttUsrNomePrestador", txtNome.getText().toString());
                                            hopperRef3.updateChildren(hopperUpdates3);
                                            //=================================================
                                        }
                                    }

                                    @Override
                                    public void onCancelled(DatabaseError databaseError) {

                                    }
                                };
                                firebaseContato.addListenerForSingleValueEvent(valueEventListenerContato);
                            }
                        }
                    }

                    @Override
                    public void onCancelled(DatabaseError databaseError) {

                    }
                };
                firebase.addListenerForSingleValueEvent(valueEventListener);
    
03.08.2018 / 21:47