title: Callback in Firebase android
body: <p>After create data on Firebase. I try retrieving data from Firebase. But I have problem, I think may be Log.d(TAG,list.size()) run before ref.addChildEventListener(childEventListener); complete. Who can help me ? </p>
  
  <pre><code>public class NewFirebase extends AppCompatActivity {
  
      List &lt; Product &gt; list = new ArrayList &lt; &gt; ();
      private static final String TAG = "Firebase";
      DatabaseReference ref;
      @Override
      protected void onCreate(@Nullable Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          Firebase.setAndroidContext(this);
          ref = FirebaseDatabase.getInstance().getReference();
          ChildEventListener childEventListener = new ChildEventListener() {
              @Override
              public void onChildAdded(DataSnapshot dataSnapshot, String previousChildName) {
                  Log.d(TAG, "onChildAdded:" + dataSnapshot.getKey());
  
                  // A new comment has been added, add it to the displayed list
                  Product comment = dataSnapshot.getValue(Product.class);
                  for (DataSnapshot child: dataSnapshot.getChildren()) {
                      Product post = child.getValue(Product.class);
                      list.add(post);
                  }
                  // ...
              }
  
              @Override
              public void onChildChanged(DataSnapshot dataSnapshot, String previousChildName) {
                  Log.d(TAG, "onChildChanged:" + dataSnapshot.getKey());
  
              }
  
              @Override
              public void onChildRemoved(DataSnapshot dataSnapshot) {
                  Log.d(TAG, "onChildRemoved:" + dataSnapshot.getKey());
  
              }
  
              @Override
              public void onChildMoved(DataSnapshot dataSnapshot, String previousChildName) {
                  Log.d(TAG, "onChildMoved:" + dataSnapshot.getKey());
  
              }
  
              @Override
              public void onCancelled(DatabaseError databaseError) {
                  Log.w(TAG, "postComments:onCancelled", databaseError.toException());
  
              }
          };
          ref.addChildEventListener(childEventListener);
          Log.d(TAG, list.size() + "");
      }
  
      class RetrievingData extends AsyncTask &lt; Void, Void, Void &gt; {
  
          @Override
          protected Void doInBackground(Void...voids) {
  
              return null;
  
          }
      }
  }
  </code></pre>