title: Waiting for a specific operation - Android
body: <p>I want to wait for a specific operation to complete before continuing the code flow.
  Something like this:</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
  
  downloadSomeFiles(); // I want to wait for this operation to finish
  Log.d("Download", "Download Complete") //This should run After downloading completed
  }
  </code></pre>
  
  <p>However downloading takes some time and I always end up getting NullPointerException because downloading wasn't completed.
  Assume we don't know how long we must wait.</p>