2014-03-04 761 views
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) 

    } 

我在哪里错了?
我可以修复它吗?

+0

目录正在创建,甚至目录也没有得到创建 – praveen

+0

@praveen我有sdcard.so文件夹创建 –

+1

尝试观察Logcat你得到任何异常etc.then你可能会解决问题或者发布你的logcat。 – praveen

回答

0

我会大胆地猜测,说了,因为你需要被访问/存储/模拟/遗留,而不是/存储/模拟/ 0

我可能是错的..但我看到有没有公认的答案所以我会给这个尝试:)

相关问题