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 had the same problem, and i solved it by disabling file transfer from device to computer.
Because if u enable file transfer, sd card is not accessible to debugging application.