Firebase: How to check if a child exist on different path?

enter image description here

I am trying to check if "1122334455" (mobile number) is a child within Teachers folder. Computer Science and Mechanical are both departments, and both include mobile numbers as their Childs.

I am able to check if a mobile number exists at a particular path using this

reference = FirebaseDatabase.getInstance().getReference("Person/Teachers/Computer Science");
if(snapshot.hasChild(mobile_number))
{

}

But what I want to achieve is to determine if the person exists using just their mobile number when it is not known if they're teacher or student, whether they belong to CS or mechanical. But this code does not work.

reference = FirebaseDatabase.getInstance().getReference("Person/");
if(snapshot.hasChild(mobile_number))
{

}

Also tried snapshot.child(mobile_number).exists(), that also doesn't work.



Read more here: https://stackoverflow.com/questions/67930745/firebase-how-to-check-if-a-child-exist-on-different-path

Content Attribution

This content was originally published by ohmfischer at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: