I am developing an application for google tv and I would like to read an image from a USB Flash Drive connected to the google tv and show it in my application. I already know how to show the image but I dont know how to read it from the usb. I tried with this code:
File imgFile = new File("sdcard/image/1.jpg");
But it doesn't work for the usb.
There is no public API to access the USB devices as a file system. getExternalStorageDirectory()
is not the solution.
To address this lack, I suggest to have a look at libmedia, a library designed as a toolbox to help developers to build applications.
As simple as:
VolumeManager volumeManager = new VolumeManager();
List<Volume> volumes = volumeManager.getVolumes();
Volume volume = volumes.get(0); // simplified
File rootFolder = volume.getRoot();
File imgFile = new File(rootFolder, "image/1.jpg");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With