// create a File object for the parent directory
File fileDirectory = new File(Environment.getExternalStorageDirectory()+"/filexxxx");
// have the object build the directory structure, if needed.
fileDirectory.mkdirs();
File file = new File( fileDirectory.getAbsolutePath(),filename );
FileOutputStream fos = new FileOutputStream(file);