The official method Environment.getExternalStorageDirectory() seems to be not working on Samsung devices...
It return "/sdcard/" but not the real path "/sdcard/external_sd/", you could refer to the following post
Android SD Card Characteristics on Samsung Galaxy
Is there another methods to detect the external real storage path and suitable for all devices ?? or just teach me how to avoid this issue ??
Thanks.
On your Android phone, go to Settings> Storage, find SD card section. If it shows “Mount SD card” or “Unmount SD card” option, perform these operations to fix the problem. This solution has been proved to be able to solve some SD card not recognized problems.
You can transfer the contents from the old phone to a microSD card, and then restore the contents on your new Galaxy phone.
I hope the code below is helpful. That code finds the path of removable external storage (i.e. SD card).
File file = new File("/system/etc/vold.fstab");
FileReader fr = null;
BufferedReader br = null;
try {
fr = new FileReader(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
if (fr != null) {
br = new BufferedReader(fr);
String s = br.readLine();
while (s != null) {
if (s.startsWith("dev_mount")) {
String[] tokens = s.split("\\s");
path = tokens[2]; //mount_point
if (!Environment.getExternalStorageDirectory().getAbsolutePath().equals(path)) {
break;
}
}
s = br.readLine();
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fr != null) {
fr.close();
}
if (br != null) {
br.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With