title: Unable to get the current downloading file size using Android Download Manager
body: <p>I call the service below to handle the download of a given URL. As you can see in the snippet below I want to assign the current downloading file size to <code>total_size</code>.</p>
  
  <p>However (using the Eclipse debugger) its value remains -1 even though the file is getting properly downloaded. Suggestions?</p>
  
  <pre><code>public class DownloadManagerService extends IntentService {
  
      public final static String ACTION_DOWNLOAD_STARTED= "com.youzik.app.intent.action.ACTION_DOWNLOAD_STARTED";
      public static final String DATA = "download";
      public static final String URL = "url";
  
      public DownloadManagerService() {
          super("DownloadManagerService");
      }
  
      @Override
      protected void onHandleIntent(Intent service) {
          Request request = new Request(Uri.parse(service.getStringExtra(URL)));
          DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
          long downloadId = downloadManager.enqueue(request);
  
          Cursor cursor = downloadManager.query(new DownloadManager.Query().setFilterById(downloadId));
  
          if (!cursor.moveToFirst()) {
              Log.v("DownloadManagerService", "download list is empty");
              return;
          }
  
          Download dl = new Download();
          dl.setId(cursor.getLong(cursor.getColumnIndex(DownloadManager.COLUMN_ID)));
          dl.setName(cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_TITLE)));
          dl.setUrl(cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)));
  
          int total_size = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_TOTAL_SIZE_BYTES));
  
          cursor.close();
      }
  
  }
  </code></pre>