0
我從庫中打開圖像,調整大小並嘗試將調整後的版本保存到應用程序數據文件中,以便將來可以抓取它。我的問題是,當我嘗試用輸入流寫入時,我不斷收到FileNotFoundException。將編輯後的圖像保存到SD卡
這是它試圖寫入的文件。 「/mnt/sdcard/Android/data/foundcake.myslide/files/IMG_20100918_133128.png」
我是否錯過了這裏的重要步驟?
File storagePath = new File(Environment.getExternalStorageDirectory() + "/Android/data/foundcake.myslide/files/");
storagePath.mkdirs();
Debug.print("STORAGE PATH " + storagePath);
Pattern pattern = Pattern.compile("/([^/]+)\\.[^/]+$");
Matcher matcher = pattern.matcher(filePath);
String fileName = "";
while (matcher.find()) {
fileName = matcher.group(1);
}
Debug.print("FILE NAME " + fileName);
File cached = new File(storagePath, fileName + ".png");
Debug.print("NEW FILE " + cached.toString());
try {
FileOutputStream out = new FileOutputStream(cached);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
} catch (Exception e) {
e.printStackTrace();
}