I would like to know how to recover from FireBase a single FireBase data, I used the EventListener structure by mounting the object and pulling only one of the data, but when I run the error app and it closes, it may be an error in the specified path, but I do not know how to proceed. How do I retrieve only 1 of the data from a node ???
Fragment
public class fragmentPerfil extends Fragment {
private DatabaseReference databaseReference;
private FirebaseAuth autenticacao;
private TextView nome;
private String usuarioLogado;
public fragmentPerfil() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_noticias, container, false);
nome = (TextView) view.findViewById(R.id.txt_nome);
autenticacao = FirebaseConfig.getAutenticacao();
autenticacao.getCurrentUser();
usuarioLogado = autenticacao.getCurrentUser().getUid();
databaseReference = FirebaseConfig.getFirebase().child("Usuarios").child(usuarioLogado);
databaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Usuarios user = dataSnapshot.getValue(Usuarios.class);
nome.setText(user.getNome());
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
return view;
}
}