【发布时间】:2023-04-06 00:37:02
【问题描述】:
我正在制作使用 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);
【问题讨论】:
标签: android illegalstateexception create-directory