1) After downloading a .docx/pdf file in android studio through download manager it shows me a message "Unreadable content in file. Do you want to recover it?"
2) But when i download a jpg or a mp3, it works fine.
My code:
private long DownloadData (Uri uri, View v) {
long downloadReference;
downloadManager = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(uri);
//Setting title of request
request.setTitle("ZoraizCV");
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
//Setting description of request
request.setDescription("Android Data download using DownloadManager.");
//Set the local destination for the downloaded file to a path within the application's external files directory
if(v.getId() == R.id.DownloadMusic)
request.setDestinationInExternalFilesDir(MainActivity.this, Environment.DIRECTORY_DOWNLOADS,"zoraizCV.docx");
request.allowScanningByMediaScanner();
//Enqueue download and save the referenceId
downloadReference = downloadManager.enqueue(request);
Button DownloadStatus = (Button) findViewById(R.id.DownloadStatus);
DownloadStatus.setEnabled(true);
Button CancelDownload = (Button) findViewById(R.id.CancelDownload);
CancelDownload.setEnabled(true);
return downloadReference;
}