request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,nameOfFile);
How to read the downloaded file from that dir.
File file = new File(Environment.DIRECTORY_DOWNLOADS,nameOfFile);
MimeTypeMap map = MimeTypeMap.getSingleton();
String ext = MimeTypeMap.getFileExtensionFromUrl(file.getName());
String type = map.getMimeTypeFromExtension(ext);
Getting the error that file could not be accessed.
You will have to use the function: getExternalStoragePublicDirectory()
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), nameOfFile);
See the Android API Documentation