저는 SD카드 경로 땡길때 아래와 같이 쓰고있습니다.
4.2 도 문제없내영
public final String SD_CARD_PATH = getMount_sd();
@TargetApi(9)
public String getMount_sd() {
List<String> mountList = new ArrayList<String>();
String mount_sdcard = null;
Scanner scanner = null;
try {
File vold_fstab = new File("/system/etc/vold.fstab");
scanner = new Scanner(new FileInputStream(vold_fstab));
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
if (line.startsWith("dev_mount") || line.startsWith("fuse_mount")) {
String path = line.replaceAll("\t", " ").split(" ")[2];
if (!mountList.contains(path)){
mountList.add(path);
}
}
}
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} finally {
if (scanner != null) {
scanner.close();
}
}
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD){
if (!Environment.isExternalStorageRemovable()) {
mountList.remove(Environment.getExternalStorageDirectory().getPath());
}
}
for (int i = 0; i < mountList.size(); i++) {
if (!isMounted(mountList.get(i))){
mountList.remove(i--);
}
}
if(mountList.size() > 0){
mount_sdcard = mountList.get(0);
}
return mount_sdcard;
}
public boolean isMounted(String path) {
boolean isMounted = false;
Scanner scanner = null;
try {
File mounts = new File("/proc/mounts");
scanner = new Scanner(new FileInputStream(mounts));
while (scanner.hasNextLine()) {
if (scanner.nextLine().contains(path)) {
isMounted = true;
break;
}
}
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} finally {
if (scanner != null) {
scanner.close();
}
}
return isMounted;
}