First, I'd like to start by saying, yes I have read and tried just about every single question on this topic posted to SO, so please do not link me to other answers. For example, I have tried something like this, but it returns the same as internal storage. I have about 12GB internal storage and 4GB SD card storage, but no matter what method I use, I always get the exact same number for the SD space as I do for internal space. Are there any other methods to obtaining SD card space?
Asked
Active
Viewed 553 times
4
-
Have you tried this? http://www.41post.com/4374/programming/android-obtaining-sd-card-memory-information – Lexandro Jul 06 '14 at 08:12
-
This might help http://stackoverflow.com/questions/7829300/getting-the-size-of-a-micro-sd-card-via-c (in C/C++, but it'd be something similar for Java) – PandaConda Jul 06 '14 at 10:07
-
1@PandaConda Thanks, I tried that implementation in Java, but a value of 0 was returned. – ArmaAK Jul 06 '14 at 22:18
-
If y'all are curious, I've answered with some code I wrote below. – ArmaAK Jul 07 '14 at 06:22
1 Answers
1
Well, I ended up writing a bit of code that uses the file /etc/vold.fstab
to get all the actual external storage devices. On my TF101 with the docking station attached and populated with storage devices, this will correctly return the path to the microSD, SD, and usb drives.
private ArrayList<String> extStorageLoc(){
String[] toSearch = readFile("/etc/vold.fstab").split(" ");
ArrayList<String> out = new ArrayList<String>();
for(int i = 0; i < toSearch.length; i++){
if(toSearch[i].contains("dev_mount")){
if(new File(toSearch[i+2]).exists()){
out.add(toSearch[i+2]);
}
}
}
return out;
}

ArmaAK
- 587
- 6
- 21