I try to download an image with this code and save it : in this line:
OutputStream os =new FileOutputStream(f);
i try it on the emulator.my
Your way to detect external storage location is better than the answer of Munish Kapoor as /sdcard is not always the right folder path.
But afterwards, are you sure that /myfolder exists as a folder. You should create a file that points to that location and call mkdirs on it to create it.
After that, save your file inside.