Skip to content
loading...

How to read SD card in android

sandeepkamboj12 profile image Sandeep kamboj twitter logo github logo ・1 min read

In android Environment.getExternalStorageDirectory() is used to read the external storage of android device. But it reads Internal Memory of device not SD card.

So there is other method to read the SD card in android device.


String sdcard_path = System.getenv("SECONDARY_STORAGE");


It returns the path of sd card. To check whether SD card in inserted in device or not following code is used to do that.

    public boolean isCard()
    {

        return new File(System.getenv("SECONDARY_STORAGE")).exists();

    }

twitter logo DISCUSS
Discussion
markdown guide
Classic DEV Post from Jul 30 '19

PublishTo.Dev: Scheduling article publishing on dev.to

Sandeep kamboj profile image
Android and Web Developer