This is my Firebase Database and I'm developing an android application. Now in "Generated" node, I want to fetch only that child who's "userId" matches to current user's UID.
Now in below-given code, I'm using "equalTo()" to match the user id. But "equalTo()" is not giving the desired result when it uses a variable in it. Instead of that when I insert the user's UID manually (coping from Firebase console and pasting it into ".equalTo()" the given query works absolutely fine.
firebaseAuth = FirebaseAuth.getInstance();
firebaseUser = firebaseAuth.getCurrentUser();
firebaseDatabase = FirebaseDatabase.getInstance();
databaseReference = firebaseDatabase.getReference("Leads");
populatingGeneratedLeads = databaseReference.child("Generated").orderByChild("userId").equalTo(current_userid);
//Getting User UID
if (firebaseUser != null) {
current_userid = firebaseUser.getUid();
}
So can someone guide me how to insert a value in "equalsTo()" through a variable.