Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I agree with @Salw<br> Please see below code:</p> <pre><code>-------------end-------------- public static HashSet&lt;String&gt; getStorageSet(){ HashSet&lt;String&gt; storageSet = getStorageSet(new File("/system/etc/vold.fstab"), true); storageSet.addAll(getStorageSet(new File("/proc/mounts"), false)); if (storageSet == null || storageSet.isEmpty()) { storageSet = new HashSet&lt;String&gt;(); storageSet.add(Environment.getExternalStorageDirectory().getAbsolutePath()); } return storageSet; } public static HashSet&lt;String&gt; getStorageSet(File file, boolean is_fstab_file) { HashSet&lt;String&gt; storageSet = new HashSet&lt;String&gt;(); BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); String line; while ((line = reader.readLine()) != null) { HashSet&lt;String&gt; _storage = null; if (is_fstab_file) { _storage = parseVoldFile(line); } else { _storage = parseMountsFile(line); } if (_storage == null) continue; storageSet.addAll(_storage); } } catch (Exception e) { e.printStackTrace(); }finally{ try { reader.close(); } catch (Exception e) { e.printStackTrace(); } reader = null; } /* * set default external storage */ storageSet.add(Environment.getExternalStorageDirectory().getAbsolutePath()); return storageSet; } private static HashSet&lt;String&gt; parseMountsFile(String str) { if (str == null) return null; if (str.length()==0) return null; if (str.startsWith("#")) return null; HashSet&lt;String&gt; storageSet = new HashSet&lt;String&gt;(); /* * /dev/block/vold/179:19 /mnt/sdcard2 vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0002,dmask=0002,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0 * /dev/block/vold/179:33 /mnt/sdcard vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0002,dmask=0002,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0 */ Pattern patter = Pattern.compile("/dev/block/vold.*?(/mnt/.+?) vfat .*"); Matcher matcher = patter.matcher(str); boolean b = matcher.find(); if (b) { String _group = matcher.group(1); storageSet.add(_group); } return storageSet; } private static HashSet&lt;String&gt; parseVoldFile(String str) { if (str == null) return null; if (str.length()==0) return null; if (str.startsWith("#")) return null; HashSet&lt;String&gt; storageSet = new HashSet&lt;String&gt;(); /* * dev_mount sdcard /mnt/sdcard auto /devices/platform/msm_sdcc.1/mmc_host * dev_mount SdCard /mnt/sdcard/extStorages /mnt/sdcard/extStorages/SdCard auto sd /devices/platform/s3c-sdhci.2/mmc_host/mmc1 */ Pattern patter1 = Pattern.compile("(/mnt/[^ ]+?)((?=[ ]+auto[ ]+)|(?=[ ]+(\\d*[ ]+)))"); /* * dev_mount ins /mnt/emmc emmc /devices/platform/msm_sdcc.3/mmc_host */ Pattern patter2 = Pattern.compile("(/mnt/.+?)[ ]+"); Matcher matcher1 = patter1.matcher(str); boolean b1 = matcher1.find(); if (b1) { String _group = matcher1.group(1); storageSet.add(_group); } Matcher matcher2 = patter2.matcher(str); boolean b2 = matcher2.find(); if (!b1 &amp;&amp; b2) { String _group = matcher2.group(1); storageSet.add(_group); } /* * dev_mount ins /storage/emmc emmc /devices/sdi2/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p */ Pattern patter3 = Pattern.compile("/.+?(?= )"); Matcher matcher3 = patter3.matcher(str); boolean b3 = matcher3.find(); if (!b1 &amp;&amp; !b2 &amp;&amp; b3) { String _group = matcher3.group(1); storageSet.add(_group); } return storageSet; } -------------end-------------- </code></pre> <p>You can call getStorageSet() method to get all storages. But you need check which are available. <br> <strong>Refernce</strong><br> <a href="http://sapienmobile.com/?p=204" rel="nofollow noreferrer">http://sapienmobile.com/?p=204</a> <br> <a href="https://stackoverflow.com/questions/5694933/find-an-external-sd-card-location">Find an external SD card location</a> <br> <a href="http://renzhi.ca/2012/02/03/how-to-list-all-sd-cards-on-android/" rel="nofollow noreferrer">http://renzhi.ca/2012/02/03/how-to-list-all-sd-cards-on-android/</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload