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.:
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
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.