Pregunta

I am creating a music player type app in Android.

So that i need to find all the mp3 files available in the phone,and display in a ListView.

So that i want to access external memory card of device.

I tries this,

Environment.getExternalStorageDirectory().getPath()

But this code points to internal sd card of device not external memory card.

So how can i access external memory card of device programmatically ?

Thanks in advance

¿Fue útil?

Solución

First you can get a directory path like this ..

File storageDir = new File("/mnt/");
if (storageDir.isDirectory()) {
    String[] dirList = storageDir.list();
    //check here
}

Or

// Internal Storage
new File("/mnt/external_sd/")

// External Storage
new File("/mnt/extSdCard/")

Otros consejos

In some phones internal and external refer to the same location

Try using this

if (android.os.Environment.getExternalStorageState().equals(
            android.os.Environment.MEDIA_MOUNTED)) {

     //use Environment.getExternalStorageDirectory() here

}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top