我想把一个 bitmap保存到图片目录中。以下是代码:
File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File file = new File(path, "test1.PNG");
try {
path.mkdirs();
OutputStream out = new FileOutputStream(file);
mBitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
Log.w("ExternalStorage", "Error writing " + file, e);
}
程序执行在OutputStream out = new FileOutputStream(file);
这句语句时出现问题。我使用调试器,然后全路径中返回mnt/sdcard/Pictures/test1.PNG
。是mnt/
的问题吗?为什么不能获得OutputStream out = new FileOutputStream(file);
?在文件目录中我只能看见sdcard/
。
谢谢大家指导!