我已经使用以下方法在我的 Android 设备中创建了一个目录或路径:
File dlFile = new File(Environment.getExternalStorageDirectory()
+ "/RAS/download/files");
我从我的服务器下载了一个文件:
Uri uri = Uri.parse("http://IPADDRESS/RAS/phpword/outputs/template.docx");
downloadManager = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(uri);
如何将下载的文件放入我创建的目录或路径?
最佳答案
试试这个
DownloadManager.Request request = new DownloadManager.Request(
downloadUri);
request.setAllowedNetworkTypes(
DownloadManager.Request.NETWORK_WIFI
| DownloadManager.Request.NETWORK_MOBILE)
.setAllowedOverRoaming(false).setTitle("Data")
.setDescription("Downloading")
.setDestinationInExternalPublicDir("/RAS/download/files", "test.docx");
mgr.enqueue(request);
这是您提供路径的行
setDestinationInExternalPublicDir("/RAS/download/files", "test.docx");
关于java - 如何下载创建的目录中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59189012/