Unable to write files in Android P

不羁岁月 提交于 2019-12-02 02:26:25

问题


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.


回答1:


Used DocumentContract and DocumentFile to create files and folders using URI.



来源:https://stackoverflow.com/questions/51922592/unable-to-write-files-in-android-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!