Intent intent = new Intent();
intent = getIntent();
contactUri = intent.getData();
Uri src_uri = Uri.parse(contactUri.getPath());
Uri dst_uri = Uri.parse("file:///mnt/sdcard/download/testing.pdf");
DownloadManager.Request req = new DownloadManager.Request(src_uri);
req.setDestinationUri(dst_uri);
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(req);
or
dmr.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
dmr.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
dmr.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
DownloadManager manager = (DownloadManager) mContext.getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(dmr);
What I have tried:
i want to get the path of downloaded file or set it manually. Using above code will suddenly stop my app. I have include permisions in manifest also.