title: Cannot get status of download manager in android
body: <p>I am working with android.I am trying to get the status of downloading using download manager.But it does not work. I used the following code</p>
  
  <pre><code>    DownloadManager.Query query = null;
      Log.i("service1", "blah");
      Cursor c = null;
      DownloadManager downloadManager = null;
      downloadManager = (DownloadManager)getSystemService(Context.DOWNLOAD_SERVICE);
      Log.i("service2", "blah");
      query = new DownloadManager.Query();
       if(query!=null) {
           Log.i("service3", "blah");
                  query.setFilterByStatus(DownloadManager.STATUS_FAILED|DownloadManager.STATUS_PAUSED|DownloadManager.STATUS_SUCCESSFUL|
                          DownloadManager.STATUS_RUNNING|DownloadManager.STATUS_PENDING);
              } else {
                  Log.i("service4", "blah");
                  return;
              }
      c = downloadManager.query(query);
      if(c.moveToFirst()) { 
          Log.i("service5", "blah");
      int status = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS)); 
      Log.i("service6", "blah");
      switch(status) { 
      case DownloadManager.STATUS_PAUSED: 
      break; 
      case DownloadManager.STATUS_PENDING: 
      break; 
      case DownloadManager.STATUS_RUNNING: 
          Toast.makeText(this, "Download started", Toast.LENGTH_SHORT).show();
      break; 
      case DownloadManager.STATUS_SUCCESSFUL: 
          Toast.makeText(this, "Download completed", Toast.LENGTH_SHORT).show();
      break; 
      case DownloadManager.STATUS_FAILED: 
      break; 
      }
     }
  </code></pre>
  
  <p>It does not enter into if(c.moveToFirst()). Or any other way to get the download status in Android?</p>