title: Retrieve Data using Multiple keys Firebase Realtime Database
body: <p><a href="https://i.stack.imgur.com/xjX55.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xjX55.jpg" alt="enter image description here"></a>I have a list of Keys in a Array List . I want to retrieve data only from those keys but at a same time.</p>
  
  <pre><code>      DatabaseReference mDBRef;
  
        List&lt;String&gt; keys = new ArrayList&lt;&gt;();
  </code></pre>
  
  <p>I tried this with loop but the result coming in Model class is repeated 2 times.</p>
  
  <pre><code>            for (int i= 0;i&lt;keys.size();i++)
              {
                  String id = keys.get(i);
                  Log.d("Keys",id);
                  mDBRef = FirebaseDatabase.getInstance().getReference().child("Gyms").child(id);
  
  
                  mDBRef.addListenerForSingleValueEvent(new ValueEventListener() {
                      @Override
                      public void onDataChange(final DataSnapshot dataSnapshot) {
  
                          dataSnapshot.getKey();
                           gyms = dataSnapshot.getValue(Gyms.class);
  
  
                          if (gyms != null)
                          {
                              Log.d("Names",gyms.getName());
  
                              Toast.makeText(NearMeActivity.this, ""+ gyms.getName(), Toast.LENGTH_SHORT).show();
  
                          }
                      }
  
                      @Override
                      public void onCancelled(DatabaseError databaseError) {
  
                      }
                  });
              }
  </code></pre>