, если вы загружаете файлы из хранилища Firebase, попробуйте этот код
private void getFileUrl(){
StorageReference storageReference = FirebaseStorage.getInstance().getReference().child("your file name as is from firebase storage");
storageReference.getDownloadUrl().addOnSuccessListener(uri -> {
String url = uri.toString();
downloadFile(getContext(), "your file name", "file extension", DIRECTORY_DOWNLOADS, url);
mProgressBar.hide();
}).addOnFailureListener(e -> {
mProgressBar.hide();
ToastUtil.toastLong(getContext(), "something went wrong " + e.getMessage());
});
}
private void downloadFile(Context context, String fileName, String fileExtension, String destinationDirectory, String url) {
DownloadManager downloadmanager = (DownloadManager) context.
getSystemService(Context.DOWNLOAD_SERVICE);
Uri uri = Uri.parse(url);
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalFilesDir(context, destinationDirectory, fileName + fileExtension);
downloadmanager.enqueue(request);
}
дайте мне знать, если это работает.