I m trying to write a bitmap to an sdcard on android, and I get the error message of
/mnt/sdcard/PhysicsSketchpad/sketchpad145.png (No such file or directory).
I declared the android.permission.WRITE_EXTERNAL_STORAGE
permission in the manifest, and this is my code:
String file_path = Environment.getExternalStorageDirectory().getAbsolutePath() +
"/PhysicsSketchpad/";
File dir = new File(file_path);
dir.mkdirs();
File file = new File(dir, "sketchpad" + pad.t_id + ".png");
FileOutputStream fOut = new FileOutputStream(file);
bmp.compress(Bitmap.CompressFormat.PNG, 85, fOut);
fOut.flush();
fOut.close();
What s going on?
<><>>>>><>>>>><>>>>>>
似乎在我试图写给现有名录时,我获得了否认错误的许可:
。
08-11 09:55:23.796: WARN/Physics Sketchpad(8881): Error when saving: IOException /mnt/sdcard/download/sketchpad54.png (Permission denied)
并且当我试图在新目录中节省费用时,我没有发现这种档案或目录错误,08-11 09:59:20.175:WARN/Physics Sketchpad(9040):Error在储蓄时:IOException /mnt/sdcard/PhysketicsSchpad/sketpad55.png (无此类档案或目录)
此外,<代码>File.mkdirs(>)如果成功或未成功,就返回了养蜂业,并退回了伪造。