Ali Akhgar Ali Akhgar - 12 days ago 6
Java Question

get removable sd card path in android

How can i get extSdcard path in android?

There are 2 storage, first external storage in which all the phones have it but there is second storage which is called removable storage (micro sdcard).

I want to get the path to the micro sdcard in android, how is that possible?

Answer

Starting from KitKat, you have access to a method to get that directory :

Context.getExternalFilesDirs()

Note that it may return null if the SD card is not mounted or moved during the access. Also, you might need to add these permissions to your manifest file :

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Comments