10

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);
4

2 に答える 2