0

I have a method that copies a png file, but the file is created with permissions set to read only by owner. I want to change the permissions to 777. I'm not getting any errors, but the file permissions aren't changed.

private void SaveImage(Bitmap finalBitmap){
    String root = Environment.getExternalStorageDirectory().toString();
    File myDir = new File(root + "/Movies");
    String fname = desc +".mkv";
    File file = new File (myDir, fname);
    String chmod_path = (root + "/" +  fname);
    final File ch_file = new File(chmod_path);
    try {
        FileOutputStream out = new FileOutputStream(file);
        finalBitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
        out.flush();
        out.close();
        ch_file.setReadable(true, false);
        ch_file.setExecutable(true, false);
        ch_file.setWritable(true, false);
    } catch (Exception e) {
        e.printStackTrace();
    }

}
user2631279
  • 117
  • 1
  • 3
  • 16

0 Answers0