I am trying to check if a firebase node exists by using a key. E.g. I am looking if node "child_value" exists as a child of "parent_value".
E.g.
My databasereference is pointed at "parent_value".
The statement .child("child_value")
returns the node of the child value
The statement .hasChild("child_value")
returns False
What could cause this odd behaviour where checking .haschild() returns False when the child node does exist?
EDIT:code snippet
//Entire code block below is inside of another singlevaluevent listener, don't know if that would cause any problems
DatabaseReference ref = FirebaseDatabase.getInstance().getReference()
.child("Values");
ref.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull Datasnapshot dataSnapshot){
if(dataSnapshot.hasChild(key) {
//Would expect the flow to end up here since the child exists
}
else {
//Flow ends up here
}
}