I am downloading files from web server programmatically. After download is completed, I checked the file. The size ,extension and all other parameters are correct but when I
Permission
Download Fuction Code
public void downloadFile() {
String DownloadUrl = audio1;
DownloadManager.Request request1 = new DownloadManager.Request(Uri.parse(DownloadUrl));
request1.setDescription("Sample Music File"); //appears the same in Notification bar while downloading
request1.setTitle("File1.mp3");
request1.setVisibleInDownloadsUi(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
request1.allowScanningByMediaScanner();
request1.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);
}
request1.setDestinationInExternalFilesDir(getApplicationContext(), "/File", "Question1.mp3");
DownloadManager manager1 = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
Objects.requireNonNull(manager1).enqueue(request1);
if (DownloadManager.STATUS_SUCCESSFUL == 8) {
DownloadSuccess();
}
}