I need to get only true or false value, if a given String is a child of Firebase node, without getting the whole DataSnapshot of the whole node. This is for reducing the cost of Firebase Realtime download.
What I had tried:
VillazRef.child(**UID2**).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
{
if (dataSnapshot.child(VISIBLE).hasChild("OMBsclV...0X6w2"))
{
bool=true;
}
if (dataSnapshot.child(INVISIBLE).hasChild("OMBsclV...0X6w2"))
{
bool=true;
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
I think these cades VillazRef.child(**UID2**).addListenerForSingleValueEvent
return the whole datasnapshot of this location, but I don't want this, its totally a waste of my bandwidth, so
I need only like
if("OMBsclV...0X6w2" is within the VillazRef.child(**UID2**))
{
bool=true;
}
else
{
bool=false;
}