下载的文件会自动删除 [英] Downloaded files get deleted automatically

查看:508
本文介绍了下载的文件会自动删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用中,用户可以下载一些文件.通过Android下载管理器下载文件.但是,自从几周以来,数百名用户一直抱怨他们的文件每8到12天会自动删除,而他们甚至没有卸载该应用程序. (可能还有更多的用户不愿意抱怨相同的内容.)

In my app, there are a few files that users can download. The files get downloaded via the android download manager. But, since a few weeks now, hundreds of users have been complaining that their files automatically keep deleting every 8-12 days, without them even uninstalling the app. (There might be many more users who haven't bothered to complain about the same.)

现在,可能有许多特定于用户的原因会在少数设备上发生.但是考虑到大量用户,看来我可能做错了事.

Now, there could be a number of user-specific reasons why that would happen on a few devices. But considering the huge number of users, it seems that I might have been doing something wrong.

为什么系统/下载管理器会自动删除文件?有没有办法通知系统或下载管理器不要删除某些文件?还是我应该解决下载后重命名文件的问题,以使它们与下载管理器断开链接,并希望通过此解决问题?

Why would the system/download manager delete the files automatically? Is there a way to inform the system or the download manager to not delete certain files? Or should I just settle with renaming the files after downloading, so as to unlink them from the download manager, and hope that the problem gets solved with just that?

这是我用来下载文件的代码:

Here's the code that I use to download the files:

DownloadManager.Request request = new DownloadManager.Request(Uri.parse(trackLink));
request.setTitle(trackTitle);
request.setDestinationInExternalPublicDir("Tracks", trackTitle + ".mp3");
request.setVisibleInDownloadsUi(false);
DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(request);

推荐答案

我也遇到了这个问题.查看DownloadIdleService的源代码,看来如果将下载设置为在UI中不可见,则会在7天后将其删除,因为它们被认为是过时的". 这是来自DownloadIdleService的javadoc:

I also came across this issue. Looking at the source for DownloadIdleService it appears that if the download are set to not be visible in the UI they're deleted after 7 days as they're considered "stale". Here's the javadoc fromDownloadIdleService:

/**
 * Remove stale downloads that third-party apps probably forgot about. We
 * only consider non-visible downloads that haven't been touched in over a
 * week.
 */

查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆