在sd卡中用程序创建目录
如果要想在sd卡中的一个子目录下创造文件FileOutputStream fos = new FileOutputStream("/sdcard/Wallpaper/"+fileName); 这是错误的,需要
// 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 the OutputStream to the file object, instead of a String representation FileOutputStream fos = new FileOutputStream(outputFile); ?
当然别忘了检查sd卡存在不Environment.getExternalStorageDirectory()