Is there an universal way to find the location of an external SD card?
Please, do not be confused with External Storage.
Environment.getExternalStorage
I had an application that used a ListPreference
where the user was required to select the location of where they wanted to save something.
In that app, I scanned /proc/mounts
and /system/etc/vold.fstab
for sdcard mount points. I stored the mount points from each file into two separate ArrayList
s.
Then, I compared one list with the other and discarded items that were not in both lists. That gave me a list of root paths to each sdcard.
From there, I tested the paths with File.exists()
, File.isDirectory()
, and File.canWrite()
. If any of those tests were false, I discarded that path from the list.
Whatever was left in the list, I converted to a String[]
array so it could be used by the ListPreference
values attribute.
You can view the code here: http://sapienmobile.com/?p=204