Get sdcard directory by adb Get sdcard directory by adb android android

Get sdcard directory by adb


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:/ $ dfFilesystem             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)


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

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


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