Home » Android » How to create a gallery app for usb otg?

How to create a gallery app for usb otg?

Posted by: admin November 1, 2017 Leave a comment


I know a library called libaums but I don;t know how to open an image file using their library.


According to https://github.com/magnusja/libaums, you can actually read a file from the storage using this:

// read from a file
InputStream is = new UsbFileInputStream(file);
byte[] buffer = new byte[currentFs.getChunkSize()];

Then your buffer contains the image data, so you can convert it to e.g. a Bitmap, like this:

Bitmap bmp = BitmapFactory.decodeByteArray(buffer , 0, buffer .length);

After that you can set it to an ImageView or whatever to show it to your user.

To be short, find your File and implement this logic.