I'm opening an image from the gallery, resizing it, and attempting to save the resized version to the apps data file so I can grab it in future. My problem is I keep getting a FileNotFoundException when I try to write it with an input stream.
This is the file it's trying to write too. "/mnt/sdcard/Android/data/foundcake.myslide/files/IMG_20100918_133128.png"
Am I missing any important steps here?
    File storagePath = new File(Environment.getExternalStorageDirectory() + "/Android/data/foundcake.myslide/files/");
    storageP开发者_如何学JAVAath.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();
    }
Needed
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Whoops.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论