How to mount a USB drive on Android Things?

前端 未结 4 1941
[愿得一人]
[愿得一人] 2020-12-11 12:04

I\'m attempting to read files off of a USB drive for an Android Things app on a Raspberry Pi. I\'m able to scan the list of mounted devices like so:

<
4条回答
  •  旧时难觅i
    2020-12-11 12:37

    ADB ONLY SOLUTION

    Seem like as of now USB drives aren't mounted automatically. In order to make your code work I had to mount it manually.

    As you can see (from /proc/partitions) in the /proc partition the USB drive is detected as sda.

    ADB mounting

    • Make a directory to mount to

      mkdir /mnt/usb
      
    • Mount the device

      mount -t vfat -o rw /dev/block/sda1 /mnt/usb
      

    Now you should be able to list (and manage) the files on the USB drive both via ADB and from within the app (/mnt/usb will also be logged).

提交回复
热议问题