title: Array Index Out Of Bounds Exception length=0; index=0
body: <p>I'm using <a href="https://github.com/magnusja/libaums" rel="nofollow noreferrer">libaums</a> for reading file. I just copy from test file. But it give me an error if I'm not plug the USB.</p>
  
  <pre><code>Caused by: java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
  </code></pre>
  
  <p>this is my code.</p>
  
  <pre><code>private void discoverDevice() {
          UsbManager usbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
          UsbMassStorageDevice[] devices = UsbMassStorageDevice.getMassStorageDevices(this);
          device = devices[0];
          UsbDevice usbDevice = getIntent().getParcelableExtra(UsbManager.EXTRA_DEVICE);
          if (usbDevice != null &amp;&amp; usbManager.hasPermission(usbDevice)) {
              Log.d(TAG, "received usb device via intent");
              setupDevice();
          } else {
              PendingIntent permissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0);
              usbManager.requestPermission(device.getUsbDevice(), permissionIntent);
          }
      }
  </code></pre>