调用删除时,Android DownloadManager不删除物理文件

时间:2016-01-12 11:51:17

标签: android android-download-manager

我在使用DownloadManager类从我的服务器下载视频时注意到一些奇怪的行为。

视频下载得很好,但当我尝试使用public int remove (long... ids)功能删除它们时,物理文件不会被删除,内存最终也不会被释放。

以下是我将DownloadManager.Request对象提供给DownloadManager的enqueue函数的方法:

Uri target = Uri.fromFile(new File(destinationFolder, Sha1Util.SHA1(url)));
Request request = new Request(Uri.parse(url));
request.setDestinationUri(target);
request.setNotificationVisibility(Request.VISIBILITY_HIDDEN);
request.setVisibleInDownloadsUi(false);

其中destinationFolder = /storage/emulated/0/Android/data/{app's_package_name}/{user_name}

注意:删除功能在Lollipop设备上运行正常,但不适用于以前的版本。

0 个答案:

没有答案