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

22,958

Solution 1

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.

Solution 2

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

Solution 3

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.

Solution 4

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.

Share:
22,958
Shail Adi
Author by

Shail Adi

Java Android

Updated on July 21, 2022

Comments

  • Shail Adi
    Shail Adi almost 2 years

    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.

  • Dwight Holman
    Dwight Holman over 11 years
    Note that this is a link to a file manager, not a program to manage attached USB devices and their files.
  • Shail Adi
    Shail Adi over 11 years
    But the android device does not detect the USB devices. Have you ever tried the concept you are recommending!!
  • Techwolf
    Techwolf over 11 years
    That's what it does on my phone. What device are you using?
  • Shail Adi
    Shail Adi over 11 years
    LG Optimus...can you hint me with the code implementation to detect the usb.
  • Techwolf
    Techwolf over 11 years
    What version of Android does it run? This will only work on newer phones. If it doesn't work, you might have to implement it yourself, with the USB Host API. More information on that can be found here: developer.android.com/guide/topics/connectivity/usb/index.ht‌​ml
  • Shail Adi
    Shail Adi over 11 years
    But USB Host API was included from android 3.1. And then also it depends on the hardware of the device to act as a USB Host, present in the newest phones only. I thought you were suggesting something for the prior ones...
  • Shail Adi
    Shail Adi over 11 years
    I don't think this answer is relevant to the question.
  • Techwolf
    Techwolf over 11 years
    Whether it's implemented in phones prior to Android 4.0 I think depends on the manufacturer. Some have it, some don't.