title: Firebase - Get firebase data synchronously in for loop?
body: <p>I'm trying to download firebase data in for loop then notify RecyclerView adapter. But since firebase runs async task. I'm not able to do that. How to force firebase to run synchronously or how to know all firebase data is downloaded.</p>
  
  <p>Example code:</p>
  
  <pre><code>for(int i=0;i&lt;list.size();i++){
          FirebaseDatabase.getInstance().getReference().child(list.get(i)).addListenerForSingleValueEvent(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                  Post post = dataSnapshot.getValue(Post.class);
              }
  
              @Override
              public void onCancelled(@NonNull DatabaseError databaseError) {
  
              }
          });
      }
      //When all data is downloaded
      adapter.notifyDataSetChanged();
  </code></pre>