Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am currently trying to develop an application who access xml files on an usb device. I have read the Google Documentation about Android USB Host. Now i can detect my USB Device, discover its specifications (like PID/VID), but i can't access on the files of the USB device :(

Here is my code of the activity looking for devices :

public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_visu);


  affichage = (TextView) findViewById(R.id.afficher);
  context = VisuActivity.this.getApplicationContext();
  UsbManager manager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
  HashMap<String, UsbDevice> deviceList = manager.getDeviceList();

  Iterator<UsbDevice> deviceIterator = deviceList.values().iterator();

  if(deviceList.size()==1){
      while(deviceIterator.hasNext()){
             device = deviceIterator.next();

      }

      UsbInterface mUsbInterface = device.getInterface(0);
      UsbEndpoint endpoint = mUsbInterface.getEndpoint(0);

      UsbDeviceConnection connection = manager.openDevice(device);

   }
}
  /* What To Do Now ???? */

I have tried to find some example on the internet, but I am lost now ! :(

Anyone knows how to do for read (and eventually write) a file on a USB device ? I have heard that there is a Mass Storage protocol to follow, but i don't find or understand it !

share|improve this question
 
I might be completely wrong here, it's just a guess. But I would assume that the kernel would be mount any Mass Storage device on your system somewhere inside /mnt/ so you can just access stuff in there with the normal 'File' class –  Budius Apr 5 at 15:09
 
Yes, I have already look in that way, but there is nothing in the /mnt/ File, or even if in the path descripted by the UsbDevice Object : \dev\bus\usb\002 ! Or just a *.o File –  Manu Apr 5 at 15:24
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.