When my application starts, I check the current user\'s details in my Firebase database (I\'m storing it\'s uid for that).
I\'m attaching addListenerForSingleValueEv
Please try like this. If you can't solver by this, send share me source code for this part. ...
DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference();
mDatabase.child("users").child(uid).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()){
final HashMap dataMap = (HashMap) dataSnapshot.getValue();
for (String key : dataMap.keySet()){
Object data = dataMap.get(key);
try{
HashMap moneyData = (HashMap) data;
Money money = new Money(("", "");
}catch (ClassCastException cce){
try{
name = String.valueOf(dataMap.get("username"));
email = String.valueOf(dataMap.get("useremail"));
}catch (ClassCastException cce2){
}
}
}
// do something
}else {
// when empty data
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});