Get sdcard directory by adb

左心房为你撑大大i 提交于 2019-12-03 01:16:25
Blackbelt

If I've not misunderstood you, you're looking for something like:

emanuele@Nabucodonosor:~$ adb shell cd \$EXTERNAL_STORAGE
emanuele@Nabucodonosor:~$ adb shell ls \$EXTERNAL_STORAGE
emanuele@Nabucodonosor:~$ adb shell echo \$EXTERNAL_STORAGE

For what its worth - using the $EXTERNAL_STORAGE variable can give you misleading results. I have a HP Slate tablet here, which has the EXTERNAL_STORAGE variable set to /storage/sdcard0 . However when using df (disk free) command on shell, or even the mount command to display free space or mounts, the following becomes obvious:

shell@android:/ $ df
Filesystem             Size   Used   Free   Blksize
/dev                  452.7M  36.0K  452.7M   4096
/mnt/asec             452.7M  0.0 K  452.7M   4096
/mnt/obb              452.7M  0.0 K  452.7M   4096
/system               629.9M  468.5M  161.5M   4096
/data                 5.7 G  2.3 G  3.5 G   4096
/cache                435.9M  16.4M  419.5M   4096
/storage/sdcard0      5.7 G  2.3 G  3.5 G   4096
/mnt/external_sd      29.3G  64.0K  29.3G   32768

so, the external sd card is in fact /mnt/external_sd, instead of the value EXTERNAL_STORAGE returns(which is the internal storage)

Its better to use getExternalStorageDirectory() instead of System.getenv("EXTERNAL_STORAGE") This will give you external storage directory irrespective of device.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!