Cannot write to USB OTG mass storage device

Hi All,

I'm on an Android 5.0 device where a usb mass storage is mounted at "/storage/usbotg" via USB OTG cable.
I can access this folder with a file browser app that allows me to read/write files. Unfortunately from my app I only have read access to that folder. Please note that I set the write external storage permission as I'm able to write to device storage.

I post the following code as reference:

string Root = "/storage/usbotg";
string[] Dirs = Directory.GetDirectories(root);

string NewFolder = Path.Combine(Root, "NewFolder");
Directory.CreateDirectory(NewFolder);

This gives me an exception on the last line (but I'm able to list subdirectories in Dirs)

System.UnauthorizedAccessException
Access to the path "/storage/usbotg/NewFolder" is denied.

If I use:

string Root = "/storage/emulated/0";

everything is working fine and the "NewFolder" is created.

What I'm missing? How can I write to that folder?

I'm using Xamarin.Forms 2.5.0

Thanks for your help

Answers

  • mistikomistiko Member

    Update: cannot write to that path even from the file manager, only read, sorry. Is that normal or is it a problem of this device?
    What's the correct way of enumerating paths for usb drive on android?

    Thanks

Sign In or Register to comment.