我的下面的代码可以在某些手机中使用,而不能在其他手机中使用。
我的代码是用于保存图像。
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)
}
我哪里错了?
我怎么解决它?
答案 0 :(得分:0)
我会冒险猜测它,因为你需要访问/存储/模拟/遗留而不是/ storage / emulated / 0
我可能错了..但我发现没有可接受的答案,所以我会试一试:)