title: DownloadManager downloading files over 2.1 GB
body: <p>I am working on an app and one of the features I am working on is to download some binary files. Some of them are really big (more than several mega-bytes). Downloads are completing fine as long as the file size is less than 2 GB.</p>
  
  <p>I got stuck on a file that is 3.2GB in that I get progress updates (I am pooling the DownloadManager for progress updates), but when the download completes, the file is not present on the target file path. Interrogating the <code>DownloadManager</code> for that download id, I get <a href="http://developer.android.com/reference/android/app/DownloadManager.html#STATUS_FAILED" rel="noreferrer"><code>STATUS_FAILED</code></a> and reason <a href="http://developer.android.com/reference/android/app/DownloadManager.html#ERROR_UNKNOWN" rel="noreferrer"><code>ERROR_UNKNOWN</code></a> - the favorite error details one will ever wish for!</p>
  
  <p>What is weird is that this appears on most of the devices, but for some (like Samsung SG 4 Active OS 4.2.2 and LG Nexus 5 OS 4.4.2), it doesn't appear.</p>
  
  <p>Doing some extra investigation, I found out that this seems to be a <a href="https://code.google.com/p/android/issues/detail?id=41163" rel="noreferrer">bug in Android <code>DownloadManager</code> implementation</a>. It seems Android implementation stores the download count as an int, but when that count goes above <code>Integer.MAX_VALUE</code> the download ends as failed.</p>
  
  <p>I am thinking to replace the <code>DownloadManager</code> usage with a foreground service, but I wouldn't give up yet .... </p>
  
  <p>Did you guys face this and if so, how did you fix it?
  Is there any work-around to use <code>DownloadManager</code> in pre-4.2.2 so I can download more than 2.1 GB per file?</p>