Android - How can I determine storage directory from ADB?
adb shell echo $EXTERNAL_STORAGE
. All credit goes to Flow for leading me to experiment and find this.
Naturally you can use cd $EXTERNAL_STORAGE
or whatever else you might need during an adb shell session or from a terminal emulator.
I don't think that this is possible. See Matthew's Post
But let's have a lock on how Environment.getExternalStorageDirectory()
returns the external storage directory. A quick look in android/os/Environment.java
shows that all this method does, is returning a static constant File member called EXTERNAL_STORAGE_DIRECTORY
. This constant is initialized by
private static final File EXTERNAL_STORAGE_DIRECTORY
= getDirectory("EXTERNAL_STORAGE", "/sdcard");
which calls getDirectory()
static File getDirectory(String variableName, String defaultPath) {
String path = System.getenv(variableName);
return path == null ? new File(defaultPath) : new File(path);
}
So the external storage directory is nothing else then an java System environment variable (or a predefined default). You could try to follow this trace further. Maybe the external storage directory is just a hard coded path in some configuration file on the filesystem. Or maybe there is a way to read out these environment variables via adb
that I don't know.