Permission denied on Android - kind: PermissionDenied, message: "Permission denied"

I have a FileManager app in Android (For UI) which uses a rust library internally (To do all the heavy lifting like CRUD File Operation). This app handles Usb drive also.

When I attach a USB drive to phone, I take all the necessary permissions from users like Usb access permission, Usb Read/Write permission, Android Phone Storage permission etc.

I am able to do Write operations on My Usb drive using the Rust standard library (std::fs), But on some of the OEM's (Samsung, Asus, and some other, Irrespective of Android versions) It fails with error
"Os { code: 13, kind: PermissionDenied, message: "Permission denied" }"

E.g, When I create a directory using below code, If give me success for some OEMs, But at the same time, It fails for Some of the devices.

match std::fs::create_dir(path) {
Ok(()) => {
println!("Directory created successfully");
Ok(true)
}
Err(err) => Err(err),
}

PS : I have taken all the permissions for Usb from user.

Don't know much about android, but doesn't modern versions (like 7 and later or so) require you to use some RPC calls via binder to access storage outside your programs private data? Scoped storage or something like that iirc.

Yes, I have already provided the Scoped Storage access to the mounted path, where the USB is getting mounted on the FileSystem, Which means User has already provided the root level access of the USB drive.
I am able to Read/Write on the Internal Storage of a device using the rust std::fs. But somehow for Some devices Rust is complaining to Write on the USB.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.