问题
run adb shell, look for the legacy link to /mnt/shell/emulated/0 But getCanonicalPath can't get /mnt/shell/emulated/0?
shell@android:/storage/emulated $ ls -l lrwxrwxrwx root root 2012-12-07 12:01 legacy -> /mnt/shell/emulated/0
File file = new File("/storage/emulated/legacy");
String pachString = null;
try {
pachString = file.getCanonicalPath();
// prints /storage/emulated/legacy
} catch (IOException e) {
e.printStackTrace();
}
回答1:
shell@android:/mnt $ ls -l /mnt/
ls -l /mnt/
drwxr-xr-x root system 2013-03-13 16:31 asec
drwxr-xr-x root system 2013-03-13 16:31 obb
lrwxrwxrwx root root 2013-03-13 16:31 sdcard -> /storage/emulated/legacy
drwx------ root root 2013-03-13 16:31 secure
drwx------ shell shell 2013-03-13 16:31 shell
'/mnt/shell'
directory is accepted shell only.
So apps cannot read /mnt/shell
.
来源:https://stackoverflow.com/questions/13757248/why-sdcard-legacy-getcanonicalpath-not-emulated-0-in-android-4-2-os