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
i.e:
Firstly I invented following solution:
But the problem is that I have two samsung devices GT-I9100
and GT-I9000
and both have a directory sdcard/external_sd
. When I am checking System.getenv("EXTERNAL_STORAGE")
one returns sdcard
and another sdcard/external_sd
. I need to pull file which was previously saved to System.getenv("EXTERNAL_STORAGE")
.
So the question is: is there any command to get sdcard directory directly from adb, without access to Android code?
Or maybe I can start activity with adb's am start, and get return value? Is this possible?
EDIT: Found the solution:
adb shell echo $EXTERNAL_STORAGE
Your first step to determining what's full is to execute in either a terminal or adb shell the command “df /sdcard” – this will display the disk space used by the internal SD. For purposes of this, the /sdcard mount point is all we're interested in, but if you want to see external space used you could do “df /sdcard2”.
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)
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With