I couldn’t write files in Android P Memory Card. The same code is working fine in Android O.
new File(file.getParent()).mkdirs();
output = new ObjectOutputStream(new FileOutputStream(file));
output.writeObject(obj);
I am able to read the files from the same device(Memory Card), but when I try to write the file, it is throwing Permission Denied exception.
Initially it was throwing me No such file or Directory, but after giving root permissions, it is throwing Permission Deniod exception.
Note: My app is system privileged app and also I have given the Devicewith root permission by adb root, checked the permissions in Android Manifest file, they look fine.
Used DocumentContract and DocumentFile to create files and folders using URI.
来源:https://stackoverflow.com/questions/51922592/unable-to-write-files-in-android-p