My application downloads a PDF file using DownloadManager and saves it to a folder in external storage.
File folder = new File(Environment.getExternalStorageDirectory(), "Class 10");
File chapterFile = new File(folder, "jess301.pdf");
request = new DownloadManager.Request(Uri.parse("http://www.ncert.nic.in/NCERTS/l/jess301.pdf"))
.setTitle("Book Name")
.setDescription("Chapter Name")
.setDestinationUri(Uri.fromFile(chapterFile))
.setVisibleInDownloadsUi(false);
downloadID = downloadManager.enqueue(request);
On many devices (e.g. nexus 4), the download manager saves the downloaded file in Class 10/jess301.pdfas expected.
But on some devices (for example, Micromax A110: version 4.0.4), the downloaded file is saved in another loaction - Class%2010/jess301.pdf. On these devices, the space character in the file path is replaced by %20.
When I run the code in an emulator with API 15, it works correctly.
All devices reporting this problem are running Android versions 3.2 to 4.1. But the code works correctly on the respective emulators.
How can I do this job correctly on all devices?
.
, StreamResult.