title: How to listen to multiple children in Firebase?
body: <p>I am currently trying to develop an app with which users can track their location. It is important that other users must not see the location of others not being in the group. </p>
  
  <p>In order to listen to location updates from all users in the group I was wandering if attaching a ChildEventListener to each location is the most efficient way. It feels a bit strange to add so many listeners to the reference. (I think of storing the uid's in a list and applying a listener to the location child with the uid). As far as I know I can't set a Listener to the parent for security reason. </p>
  
  <p>Is there any better way or is this the way to go?</p>
  
  <pre><code>{
      locations:{
          yY6qmwJLj69JGzgG:{
              "accuracy" : 23.429000854492188,
              "altitude" : 57,
              "latitude" : 3.4386667,
              "longitude" : 10.024,
              "speed" : 0,
              "time" : 1531114956000
          },
          msVYdaTy2DWcjuJ7:{
              ...
          },
          ...
      },
      groups:{
          users:{
              msVYdaTy2DWcjuJ7:true,
              yY6qmwJLj69JGzgG:true,
              ...
          },
          ...
      },
      ...
   }
  </code></pre>
  
  <p>I have currently following rules applied:</p>
  
  <pre><code>{
    "rules": {
      "groups" : {
        ".read" : false,
        ".write" : false,
        "$gid" : {
          ".read" : "auth != null",
          ".write" : "auth != null"
        }
      },
      "locations" : {
        ".read" : false,
        ".write" : false,
        "$uid" : {
          ".read" : "auth != null",
          ".write" : "auth.uid === $uid"
        }
      }
    }
  }
  </code></pre>
  
  <p>My idea:</p>
  
  <pre><code>        for(String uid : mUserList) {
              mDatabaseReference.child("locations").child(uid).addValueEventListener(myListener);
          }
  </code></pre>