public class UsbMassStorageDevice
extends java.lang.Object
getMassStorageDevices(Context). This method only returns supported
devices or if no device is connected an empty array.
After choosing a device you have to get the permission for the underlying
UsbDevice. The underlying
UsbDevice can be accessed via
getUsbDevice().
After that you need to call setupDevice(). This will initialize the
mass storage device and read the partitions (
Partition).
The supported partitions can then be accessed via getPartitions()
and you can begin to read directories and files.
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Releases the
UsbInterface and closes the
UsbDeviceConnection. |
static UsbMassStorageDevice[] |
getMassStorageDevices(android.content.Context context)
This method iterates through all connected USB devices and searches for
mass storage devices.
|
java.util.List<Partition> |
getPartitions()
Returns the available partitions of the mass storage device.
|
android.hardware.usb.UsbDevice |
getUsbDevice()
This returns the
UsbDevice which can be used
to request permission for communication. |
void |
init()
Initializes the mass storage device and determines different things like
for example the MBR or the file systems for the different partitions.
|
public static UsbMassStorageDevice[] getMassStorageDevices(android.content.Context context)
context - Context to get the UsbManagerpublic void init()
throws java.io.IOException
java.io.IOException - If reading from the physical device fails.java.lang.IllegalStateException - If permission to communicate with the underlying
UsbDevice is missing.getUsbDevice()public void close()
UsbInterface and closes the
UsbDeviceConnection. After calling this
method no further communication is possible. That means you can not read
or write from or to the partitions returned by getPartitions().public java.util.List<Partition> getPartitions()
init() before calling this method!public android.hardware.usb.UsbDevice getUsbDevice()
UsbDevice which can be used
to request permission for communication.UsbDevice used for
communication.