DEV Community

Sandeep kamboj
Sandeep kamboj

Posted on

How to read SD card in android

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();


Top comments (0)