5

Some Android 2.x tablets such as the HTC Flyer and Samsung Galaxy Tab support both internal tablet storage and an external SD card. For example on my Flyer, /sdcard and /sdcard2 are separate, with the former representing the tablet's "internal storage."

If I use Environment.getExternalStorageDirectory(), there doesn't seem to be any set rule on which of those storage locations will be returned. In using getExternalStorageDirectory(), my concern is that I'll only find media stored on one of the two storage locations.

One solution is to just hard-code scanning /sdcard* into the application, but this makes an assumption that all devices will use that as a naming scheme, and I don't consider that a safe assumption.

Is there a documented way to scan and use multiple sd card/storage locations on Android 2.x?

My goal is actually to find all audiobooks on the tablet, so I'd like to find and use all /sdcard*/Audiobooks in some documented way.

Ken Kinder
  • 12,654
  • 6
  • 50
  • 70

1 Answers1

3

Normally second sdcard is mounted within the first one.

Here is what I mean:

  • First sdcard is mounted at /mnt/sdcard.

  • The second sdcard is mounted into /mnt/sdcard/external_sd

So whenever you receive /mnt/sdcard as path for external storage and start scanning the tree, you won't miss the second sdcard (if it was also mounted).

This is not documented behavior. But Galaxy Tab behaves exactly this way. I assume this is because there is no official Android API support (i.e. no special function in Environment class) for multiple external storages.

inazaruk
  • 74,247
  • 24
  • 188
  • 156
  • Aha! I noticed /sdcard and /sdcard2 both exist, but I didn't see in adb that /sdcard2 actually pointed to /mnt/sdcard/ext_sd. Thanks! – Ken Kinder May 27 '11 at 19:36
  • 1
    I want to re-iterate what you said -- this is not documented, and it is not standard. Some device manufacturers do this. Some don't. You can not count on it being done that way, you can not count on the name of that directory being consistent, etc. There is currently no standard API in the platform for this. – hackbod May 27 '11 at 19:46
  • Yes, you're right. The name of directory may be different in different devices. But vendors are kinda forced to place second sdcard folder inside first sdcard folder to enable support for both sdcards in applications that are not aware about that second sdcard. So basically, its safe to just rely on the fact that there is one external sdcard dir (even if combination of two or more physical sdcards). – inazaruk May 27 '11 at 20:05