![](/img/trans.png)
[英]How can i get a list of files(only sound related .flac, .m4b, .mp3) and folders with them from a directory on the sd card?
[英]How can I get a list of all mp3 files on the sd card regardless of directory in android?
使用開源MusicDroid中的代碼和我在搜索此問題時找到的以下代碼,我只能獲取根目錄/ sdcard /中的mp3文件
File home = Environment.getExternalStorageDirectory();
if (home.listFiles( new Mp3Filter()).length > 0) {
for (File file : home.listFiles( new Mp3Filter())) {
songs.add(file.getAbsolutePath());
}
ArrayAdapter<String> songList = new ArrayAdapter<String>
(this,R.layout.song_item,songs);
setListAdapter(songList);
}
如何將卡中的所有mp3文件(在任何目錄中)放入我的“歌曲”列表中?
根據您的需要,您可以只查詢媒體商店。 Android每次重新安裝時都會掃描SD卡,因此MediaStore.Audio應該擁有您需要的所有信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.