2

I tried to figure out the the right external storage (additional sdcard with more space ) location of an Android device. I know from different user, that the location is not always the same. The method Environment.getExternalStorageDirectory returns me always mnt/sdcard.

I have the following variants are reported from users:

  1. mnt/sdcard/tflash
  2. mnt/sdcard/external_sd
  3. mnt/sdcard

How can I determine the real location of an external sd-card?

jonsca
  • 10,218
  • 26
  • 54
  • 62
mcfly soft
  • 11,289
  • 26
  • 98
  • 202
  • possible duplicate of [Find an external SD card location](http://stackoverflow.com/questions/5694933/find-an-external-sd-card-location) – Sean Beach Jul 18 '14 at 19:00

2 Answers2

6
Environment.getExternalStorageState() returns path to internal SD mount point like "/mnt/sdcard"

No, Environment.getExternalStorageDirectory() refers to whatever the device manufacturer considered to be "external storage". On some devices, this is removable media, like an SD card. On some devices, this is a portion of on-device flash. Here, "external storage" means "the stuff accessible via USB Mass Storage mode when mounted on a host machine", at least for Android 2.x and above.

But the question is about external SD. How to get a path like "/mnt/sdcard/external_sd" (it may differ from device to device)?

Android has no concept of "external SD", aside from external storage, as described above.

If a device manufacturer has elected to have external storage be on-board flash and also has an SD card, you will need to contact that manufacturer to determine whether or not you can use the SD card (not guaranteed) and what the rules are for using it, such as what path to use for it.

Royston Pinto
  • 6,681
  • 2
  • 28
  • 46
  • not much, actualy. Both my devices have 2 ext storages each, getExternalStorageDirectory() gives me only one of them (on one device it is sdcard, on another - it is onboard ext storage). This kinda stupid, because I can also plug flash memory via microUSB into it, even card reader. So it seems that the only way is enumerate mounted storage devices by a hand – Tertium Sep 24 '13 at 18:18
  • 1
    Great answer. Too bad it belongs to someone else, huh? http://stackoverflow.com/a/5695129/2608235 – Sean Beach Jul 18 '14 at 19:01
0

How can I determine the real location of an external sd-card?

=> Environment.getExternalStorageDirectory() gives you the exact location of your external storage device. Path may be different because it depends on the consideration of manufacturer.

For example: I found /sdcard on some HTC devices and /mnt/sdcard on some samsung devices.

So Environment.getExternalStorageDirectory() is the correct way.

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295