How to get internal sdcard path from Android device via the appium server

Hi everyone,

it try to push a file to an android device.

        File fi = new File("C:/Testfiles/hello_world.txt");
        byte[] fileContent = Files.readAllBytes(fi.toPath());
        BasicTest.driver.pushFile("/mnt/sdcard/MyFolder/hello_world.txt", fileContent);

This works fine on my Samsung device but if i try this on an Nexus it failed because the path “/mnt/sdcard/” is not correct. For nexus it should be “/storage/emulated/”.

Now my question. How can i get the correct path from the internal sdcard programaticly via the appium server? I start the appium server remote so the device is not directly connected to my pc where i execute the java script.

Thanks for help

I think you can do this with an adb shell command. Something like ‘adb shell echo $SECONDARY_STORAGE’. You may need to parse the result.

Agreed with @wreed
Sdcard path of device will vary

So command like adb shell | grep “storage” can help

Thanks for your answers @wreed @amitjaincoer191,

This works fine,

Runtime.getRuntime().exec(“adb shell echo $EXTERNAL_STORAGE”);

but my problem is that my pc is not directly connected to the Android device, so at this point i can use JSch to execute the command line remote but i hoped that the appium server has something implemented to perform the adb commands.