疑难杂症 Android 10 automatically deletes downloaded files

plucky · 2022年12月11日 · 54 次阅读

Android 10 系统自动删除已下载文件 Σ(⊙▽⊙"a

Observed behaviour On devices running Android 10 media files are deleted by the Android OS about one week after they were downloaded using the Download Manager

What is going on? In Android there is the DownloadIdleService which is responsible for cleaning up stale or orphan downloads. A stale download is defined as a download that is not visible in the system download UI. See e.g.:DownloadIdleService.java#109 The visibility of a download in the system download UI is determined by the visibleInDownloadUi property of the DownloadManager.Request class. This property is true by default. So everything should be fine… … but starting with API level 29 (Android 10/Q) this property is ignored. Only files that were downloaded to public Download directories will be visible and therefore not being deleted by the DownloadIdleService: DownloadManager.Request.html#setVisibleInDownloadsUi(boolean)

Workaround Apps that download files into non-public directories should rename them after the download successfully completes so that the DownloadIdleService does not know about them.

原文链接

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册