Access denied writing files on USB

Hello,

Unity Editor version: 3.10.0
ML2 OS version: 1.11.0
Unity SDK version: 2022.3.9
Host OS: Windows

I’m developing a Unity app for Magic Leap 2 and encountering write permission issues when trying to create a folder on a connected USB drive. It seems the USB is mounted as internal storage, but I’m getting ‘access denied’ errors. I’ve already modified the AndroidManifest.xml to include READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions (even if USB is under /storage/XXXX-XXXX), and adjusted the Player Settings in Unity. Has anyone else experienced this, and are there specific APIs or workarounds recommended for writing to USB drives in this configuration?

I can read and copy files from the USB device…

Many thanks :grinning_face:

It sounds like you’re running into Android’s scoped storage restrictions, which got stricter starting from Android 10. Even if your USB drive mounts under /storage/XXXX-XXXX, Android often treats it as external storage, meaning standard permissions alone (READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE) aren’t enough.

I’d recommend looking at this repo UnitySimpleFileBrowser —it uses Storage Access Framework which should resolve the ‘access denied’ error you’re facing.