无法在Android P中写入文件

时间:2021-10-01 23:07:01

I couldn’t write files in Android P Memory Card. The same code is working fine in Android O.

我无法在Android P存储卡中写入文件。相同的代码在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.

我能够从同一设备(存储卡)读取文件,但是当我尝试编写文件时,它会抛出Permission Denied异常。

Initially it was throwing me No such file or Directory, but after giving root permissions, it is throwing Permission Deniod exception.

最初它是扔给我没有这样的文件或目录,但在给予root权限后,它会抛出Permission Deniod异常。

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.

注意:我的应用程序是系统特权应用程序,并且我已经通过adb root授予了Devicewith root权限,检查了Android Manifest文件中的权限,它们看起来很好。

1 个解决方案

#1


0  

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

使用DocumentContract和DocumentFile使用URI创建文件和文件夹。

#1


0  

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

使用DocumentContract和DocumentFile使用URI创建文件和文件夹。