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
It is possible that the device requires that you manually give the permissions to the cell phone, check your equipment and check that the write permission is activated on your device.