0
我有下面的代码,在一些手机的工作,并不在其他手机的工作。storage/emulated/0/open faild:ENOENT(no such file or directory)?
我的代码用于保存图像。
String path = Environment.getExternalStorageDirectory().toString();
path += "/";
File fff=new File(path + "/xalopex/Mobile/");
if (!fff.exists())
fff.mkdirs();
path += "xalopex/Mobile/";
path += "lg";
File filename;
try {
filename = new File(path + ".jpg");
FileOutputStream out = new FileOutputStream(filename);
MyImageBitMap.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();
MediaStore.Images.Media.insertImage(getContentResolver(),
filename.getAbsolutePath(), filename.getName(),
filename.getName());
} catch (Exception e) {
e.printStackTrace();
//this part will run
// e is storage/emulated/0/xalopex/Mobile/lg.jpg open faild:ENOENT (no such file or directory)
}
我在哪里错了?
我可以修复它吗?
目录正在创建,甚至目录也没有得到创建 – praveen
@praveen我有sdcard.so文件夹创建 –
尝试观察Logcat你得到任何异常etc.then你可能会解决问题或者发布你的logcat。 – praveen