Java – Get the removable SD card path in android

Get the removable SD card path in android… here is a solution to the problem.

Get the removable SD card path in android

How do I get extSdcard path in android?

There are 2 storages, the first is the external storage that all phones have, but there is also a second storage called Removable Storage (Micro SDCARD).

I want to get the path of Micro SDCARD in Android, how is this possible?

Solution

Starting with KitKat, you can use a method to get the directory:

Context.getExternalFilesDirs()

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

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

Apparently some users have problems with this method and cannot return the SD card path. I this post Find some useful information about how it works and how it doesn’t, depending on the device

Related Problems and Solutions