Tôi đang tạo ứng dụng android đang sử dụng DownloadManager. Tôi muốn tải tệp xuống thư mục mà tôi đã tạo. Nhưng các nguồn này không hoạt động. Và xảy ra IllegalstateException. Tôi có thể làm gì ??Android DownloadManager exceptionstateexception không thể tạo thư mục
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);
Tôi nên làm gì nếu tôi muốn tải xuống tệp trong thư mục đặc biệt của ứng dụng? Chỉ cần tải về tập tin trong một thư mục liên tục được xác định bởi lớp môi trường và sau đó cắt/dán tập tin? bất kỳ ý tưởng? –
@AliBehzadianNejad nếu tôi nhận được đúng, tôi đã làm như sau: request.setDestinationInExternalPublicDir (Environment.DIRECTORY_DOWNLOADS, File.separator + folderName + File.separator + filename); –