0
I would like to know how to recover from Firebase a single data from Firebase, I used the structure of Eventlistener mounting the object and pulling only one of the data, but when running the error and close app, it may be error in the specified path, but I do not know how to proceed. How to do this recover only 1 of the data from one 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;
}
}