DownloadManager: upload the file to the cache section

I use the public api of the DownloadManager class, I can upload files to an SD card, the so-called external storage. However, when I tried to upload the file to other places, for example, the / cache section, it throws a security exception that says: "The destination must be on external storage."

Does anyone know how to get around this limitation and write the downloaded file to the / cache partition?

Many thanks.

+3
source share
2 answers

If you are developing a system application, there is a hidden function in DownloadManager.Request called setDestinationToSystemCache ()

This requires the following permissions:

android.permission.ACCESS_DOWNLOAD_MANAGER
android.permission.ACCESS_DOWNLOAD_MANAGER_ADVANCED"
android.permission.ACCESS_CACHE_FILESYSTEM
+3
source

/cache . DownloadManager api setDestinationUri(), "null", android /cache . , , uri "/mnt/sdcard/...", .

+1

Source: https://habr.com/ru/post/1786761/


All Articles