I am using the following code to download a file from my server then write it to the root directory of the SD card, it all works fine:
package com.downloader;
File sdCard = Environment.getExternalStorageDirectory(); File dir = new File (sdCard.getAbsolutePath() + "/dir1/dir2"); dir.mkdirs(); File file = new File(dir, "filename"); FileOutputStream f = new FileOutputStream(file); ...