我有一个复制png文件的方法,但创建的文件的权限设置为只能由所有者读取。我想将权限更改为777.我没有收到任何错误,但文件权限没有更改。
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();
}
}