I have my android activity :
try {
File root=Environment.getExternalStorageDirectory();
Log.i(\"root\",root.toString());
In Android 6 (Marshmallow) I had to explicitely check whether my app has permission "WRITE_EXTERNAL_STORAGE"
Not sure but please verify that there exists External Storage in your emulator or phone otherwise it will through exception.
Try this,,it works for me
// create a File object for the parent directory
File wallpaperDirectory = new File("/sdcard/Wallpaper/");
// have the object build the directory structure, if needed.
wallpaperDirectory.mkdirs();
// create a File object for the output file
File outputFile = new File(wallpaperDirectory, filename);
//now attach OutputStream to the file object, instead of a String representation
FileOutputStream fos = new FileOutputStream(outputFile);
GO through this for more details