我正在制作使用 DownloadManager 的 android 应用程序。我想将文件下载到我制作的文件夹中。但是这个来源不起作用。并发生 IllegalstateException。我能做些什么??
urlToDownload = Uri.parse(URL);
List<String> pathSegments = urlToDownload.getPathSegments();
request = new DownloadManager.Request(urlToDownload);
request.setTitle(Titlename);
request.setDescription("MCPE STORE");
request.setDestinationInExternalPublicDir(
Environment.getExternalStorageDirectory().getAbsolutePath() +
"/MCPE STORE", pathSegments.get(pathSegments.size()-1));
Environment.getExternalStoragePublicDirectory(
Environment.getExternalStorageDirectory().getAbsolutePath() +
"/MCPE STORE").mkdir();
latestId = downloadManager.enqueue(request);