android scanning all .mp3 files in SD Card

前端 未结 5 896

I\'m trying to scan all .mp3 files in my SD card and save its name. here is a fragment of code which is responsible for that. 1.What i\'m doing wrong? 1. Which is correct

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-16 03:01

    The problem is with what android consider as external storage. It is not always the sd card that you add to your device. the internal memory can also be external storage. /sdcard or /mnt/sdcard is the same location and it may point to your internal storage. so you have to scan the /mnt folder completely. like in some device /mnt/sdcard will be internal memory and /mnt/extSdCard will be the one you have added. File home = Environment.getExternalStorageDirectory(); this method will return the first external storage and not all.

提交回复
热议问题