The following code which consists of downloading a file from a server and save it in the storage works fine when the device has an internal storage.
But when I tried it
i have done very silly mistake. I have already put in AndroidManifest.xml
and also add permission in java file,as get permission pragmatically. But there is mistake of Manifest.permission.READ_EXTERNAL_STORAGE. Please use Manifest.permission.WRITE_EXTERNAL_STORAGE.
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, requestCode);