Using Android phone as USB Host to mount external drives to phone and accessing the memory of the external drive through phone

StackOverflow https://stackoverflow.com/questions/13081228

  •  14-07-2021
  •  | 
  •  

Question

I have been checking since some time to mount external drives to android phone i.e., if I plug external drive(hard/flash/camera) to android device, the android phone should be able to access the storage file system.

There are apps in the market which controls external devices through phone.

I can use the USB Host mode { http://developer.android.com/guide/topics/connectivity/usb/index.html } to communicate with the usb device. But USB Host and Accessory modes are directly supported in Android 3.1 (API level 12) or newer platforms.

While an app named DSLR Controller { https://play.google.com/store/apps/details?id=eu.chainfire.dslrcontroller&hl=en } , requires Android 2.1 or above. Since the application is based on accessing the camera through android phone. If the app displays the correct info, then the task of accessing the storage of camera (or any other drive) seems to be possible.

But I want to use the application in lower version as well. Any kind of help will be appreciated.

Please comment,if need any more description of the problem.

Thanks.

Was it helpful?

Solution

The only sure way of getting this done is to use API level above 12, otherwise a few phones may have support for usb host but most of them wont support it. The reason being first of all you need hardware support for usb host, even if that is present the drivers needed might not be compiled into the kernel, i did some work while trying to implement usb host on nook color, even though it had hardware support, getting usb host working took almost 2 months and a dedicated app. So its not something you will be able to do for every device. A few might support it out of the box but even those would need root and lots more work for mounting drives and all that.. the DSLR camera also does it the same way look at the requirements

- Android device with ARMv7-A or newer CPU architecture (most 1ghz+ devices)
- Not rooted: Android 3.1 or higher with USB host kernel+API support
- Rooted: Android 2.3.1 or higher with USB host kernel support

These are the only devices that can support USB host.

OTHER TIPS

You can create an application based on FileManager open source project on Github. You can specify there to identify your device. You can change these code according to your need. Here is the link Adroid-File-Manager

If you just want to be able to access USB storage (like a flash drive) you can open the files the normal Java way (java.io.File, etc). Android ICS automatically mounts flash drives under /sdcard/usbStorage/, but I'm not sure about previous versions or other types of hardware. It might still work, though, so I'd suggest that you test it and see what happens.

From the app description, Android 2.x devices need to be rooted. This suggests that they have some native implementation of the USB host code (possibly a pre-compiled kernel module they load).

Therefore, the solution for this varies based on the specific hardware and software (kernel, vendor modifications, skin) it is running.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top