Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removable storage (external) sdcard path by manufacturers

I've been Googling around but it is sooooo hard to find what manufacturers/models use which path for sdcard/external storage.

  • I am NOT talking about the internal storage path which can be found by:

Environment.getExternalStorageDirectory()

I know that getExternalStorageDirectory() sometimes points to external sdcard on some devices.

Here's what I've found some common path for external path (Not sure which manufacturer uses which path):

/emmc /mnt/sdcard/external_sd /mnt/external_sd /sdcard/sd /mnt/sdcard/bpemmctest /mnt/sdcard/_ExternalSD /mnt/sdcard-ext /mnt/Removable/MicroSD /Removable/MicroSD /mnt/external1 /mnt/extSdCard /mnt/extsd /mnt/usb_storage  <-- usb flash mount /mnt/extSdCard  <-- usb flash mount /mnt/UsbDriveA  <-- usb flash mount /mnt/UsbDriveB  <-- usb flash mount 

These are what I found by Googling around.

I need to scan entire internal + external storage + USB flash drive to look for a certain file. If I am missing any path, please add to the above list. If someone knows paths used by each manufacturers, please share with us.

like image 227
jclova Avatar asked Dec 20 '12 16:12

jclova


People also ask

How can I change my SD card path?

In this case, you need to reset your path due to your Android's structure changes. Please start App and tap “Settings” and “Change Destination to Save”, then you will find “Auto detected path on your device”, select this and reset as the new path.

What is external storage path in Android?

Android External Storage Example Code getExternalFilesDir(): It returns the path to files folder inside Android/data/data/application_package/ on the SD card. It is used to store any required files for your app (like images downloaded from web or cache files).


2 Answers

Good news! In KitKat there's now a public API for interacting with these secondary shared storage devices.

The new Context.getExternalFilesDirs() and Context.getExternalCacheDirs() methods can return multiple paths, including both primary and secondary devices. You can then iterate over them and check Environment.getStorageState() and File.getFreeSpace() to determine the best place to store your files. These methods are also available on ContextCompat in the support-v4 library.

Also note that if you're only interested in using the directories returned by Context, you no longer need the READ_ or WRITE_EXTERNAL_STORAGE permissions. Going forward, you'll always have read/write access to these directories with no additional permissions required.

Apps can also continue working on older devices by end-of-lifing their permission request like this:

<uses-permission     android:name="android.permission.WRITE_EXTERNAL_STORAGE"     android:maxSdkVersion="18" /> 
like image 126
Jeff Sharkey Avatar answered Sep 30 '22 01:09

Jeff Sharkey


I also started with a list like yours from somewhere (sorry couldn't find the original source) and continue to add some paths collected from user feedback. There are duplicate to the above list.

    /storage/sdcard1 //!< Motorola Xoom     /storage/extsdcard  //!< Samsung SGS3     /storage/sdcard0/external_sdcard  // user request     /mnt/extsdcard     /mnt/sdcard/external_sd  //!< Samsung galaxy family     /mnt/external_sd     /mnt/media_rw/sdcard1   //!< 4.4.2 on CyanogenMod S3     /removable/microsd              //!< Asus transformer prime     /mnt/emmc     /storage/external_SD            //!< LG     /storage/ext_sd                 //!< HTC One Max     /storage/removable/sdcard1      //!< Sony Xperia Z1     /data/sdext     /data/sdext2     /data/sdext3     /data/sdext4     /sdcard1                       //Sony Xperia Z     /sdcard2                       //HTC One M8s     /storage/microsd               //ASUS ZenFone 2 

For what you want to achieve (scanning all possible paths for certain files), I think it's quite impossible to do it this way (using a list of known paths). Some paths on same device even changed between android upgrade.

like image 36
oceanuz Avatar answered Sep 30 '22 01:09

oceanuz