I want to retrieve the text 'Private Group' from the child 'group' IF the child 'contacts' has the value '9aIMkiMa0bSuMLjUk3R5bLpnoQS2'. I also want to check for the same value from the other child nodes of the parent child 'questions posts'. I have struggled with it but in vain. This is the code that I have been using, but It has only produced errors.
final DatabaseReference groupsRef = FirebaseDatabase.getInstance().getReference().child("questions posts");
Query query = groupsRef.orderByChild("group").orderByChild("contacts");
query.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
arrayList.clear();
if (snapshot.exists() && snapshot.hasChild(onlineUserId)){
arrayList.add(groupsRef.getKey().toString());
arrayAdapter.notifyDataSetChanged();
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});