Android Things filesystem

北城以北 提交于 2020-01-13 20:43:09

问题


I am building this app on android things. I want to be able to give it access to media files on a USB stick or maybe even the raspberry pi's SDcard. I don't know what I'll have it do with those files yet but I just wanna know if its possible. If it isn't that's fine I have other solutions but I figured I would start with the obvious approach first.


回答1:


I'm didn't try it, but seems it's possible by the same way as in normal Android OS. To do this You should mount Your USB dongle into the filesystem somewhere e.g. in new folder /mnt/usb like in this answer of Onik or that project of Keval Patel:

Mount USB drive:

Plug you USB drive at any of the USB port in your Raspberry Pi.

Open adb shell by typing below command in terminal (Make sure your raspberry pi is connected via adb):

adb shell

Mount the USB drive by running below command in adb shell (Your USB drive should be formatted in FAT file system):

su mkdir /mnt/usb

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

where

sda1 is the first partition of the first disk (sdb1 is the first partition of the second disk, etc.) and /mnt/usb - new folder for mounted USB dongle.

Then You can access to mounted USB dongle something like this way:

File usbDongleRoot = new File("/mnt/usb");

(or something like this).

Also take a look at this answer of JBA and that repo of Shaka Huang.



来源:https://stackoverflow.com/questions/45537879/android-things-filesystem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!