title: wait until firebase retrieves data
body: <p>I want to build a method that returns a <code>child</code> value in <code>FireBase</code>. I tried to do something like this:</p>
  
  <pre><code>public String getMessage(){
  
      root.child("MessagesOnLaunch").child("Message").addListenerForSingleValueEvent(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
              message = (String) dataSnapshot.getValue();
              Log.i("4r398", "work");
          }
  
          @Override
          public void onCancelled(FirebaseError firebaseError) {
              Log.e("error", firebaseError.getMessage());
          }
      });
      return message;
  }
  </code></pre>
  
  <p>The problem is that the method returns <code>null</code> that is probably because the method doesn't wait until the listener finishes and return <code>null</code> because its the default value of <code>message</code>.
  How can I make this method wait until the listener occurs <strong>and then return the value.</strong> </p>