title: Check for a value in many child nodes in firebase real-time database
body: <p>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.</p>
  <pre><code>final DatabaseReference groupsRef = FirebaseDatabase.getInstance().getReference().child(&quot;questions posts&quot;);
      Query query = groupsRef.orderByChild(&quot;group&quot;).orderByChild(&quot;contacts&quot;);
      query.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(@NonNull DataSnapshot snapshot) {
              arrayList.clear();
            if (snapshot.exists() &amp;&amp; snapshot.hasChild(onlineUserId)){
                arrayList.add(groupsRef.getKey().toString());
                arrayAdapter.notifyDataSetChanged();
            }
          }
  
          @Override
          public void onCancelled(@NonNull DatabaseError error) {
  
          }
      });
  </code></pre>
  <p>This is the image of the database structure
  <a href="https://i.stack.imgur.com/P7g9q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P7g9q.png" alt="enter image description here" /></a></p>