Image downloaded with DownloadManager always scans to library
<p>I'm using the <a href="http://developer.android.com/reference/android/app/DownloadManager.html" rel="nofollow">DownloadManager</a> from Android 2.3.x to get twitter avatars in my application</p>

<pre><code>File f = getFile(someTwitterUrl);
if (f.exists()) {
    f.delete();
}

f.getParentFile().mkdirs();
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(someTwitterUrl))
                .setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE)
                .setAllowedOverRoaming(false)
                .setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN)
                .setDestinationUri(Uri.fromFile(f));
lastId = manager.enqueue(request);
</code></pre>

<p>Where getFile() is a slipshod method which parses the Twitter avatar URL into a local path:</p>

<pre><code>private File getFile(String url) {
    String[] imageUrlParts = url.split("/");

    String filePath = ".avatar_cache/"+imageUrlParts[imageUrlParts.length - 2] + "/" + imageUrlParts[imageUrlParts.length - 1];
    //also tried passing null to getExternalFilesDir
    return new File(ctx.getExternalFilesDir(Environment.DIRECTORY_PICTURES), filePath);
}
</code></pre>

<p>It <em>always</em> scans the resultant images to the library on my 3.2 device. According to the documentation for a <a href="http://developer.android.com/reference/android/app/DownloadManager.Request.html" rel="nofollow">DownloadManager.Request</a> it should not scan if I use setDestinationUri unless I specify with allowScanningByMediaScanner.</p>

<blockquote>
  <p>The downloaded file is not scanned by MediaScanner. But it can be made scannable by calling allowScanningByMediaScanner().</p>
</blockquote>

<p>I've also tried making the parent directory of "someFile" hidden (.avatar_cache) and added .nomedia to the parent path, and removed the sub-path twitter creates for each user (imageUrlParts[imageUrlParts.length - 2] in getFile())</p>

<p>Can anyone see my error?</p>
