Get sdcard directory by adb

前端 未结 3 1024
离开以前
离开以前 2021-02-03 22:41

I am making an application, which pulls files(Saved by android app) from the device sdcard by adb. The problem is that different devices, have various sdcard directories

相关标签:
3条回答
  • 2021-02-03 23:12

    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
    
    0 讨论(0)
  • 2021-02-03 23:18

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

    0 讨论(0)
  • 2021-02-03 23:26

    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)

    0 讨论(0)
提交回复
热议问题