how to get all all audio files from sd card android

后端 未结 4 1524
清酒与你
清酒与你 2020-12-30 16:35

I want to write a class which gets all the mp3 files from the whole sd card. But actually it only gets the audio files laying directly on the sd card. so it doesnt search tr

4条回答
  •  清歌不尽
    2020-12-30 17:07

    private void getallaudio()
        {
            String[] STAR = { "*" };
            controller.audioWrapper.clear();
            Cursor audioCursor = ((Activity) cntx).managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, STAR, null, null, null);
            if (audioCursor != null) 
            {
                if (audioCursor.moveToFirst()) 
                {
                    do 
                    {
                        String path = audioCursor.getString(audioCursor.getColumnIndex(MediaStore.Audio.Media.DATA));
                        audioWrapper.add(new MediaWrapper(new File(path).getName(), path, "Audio",false));
    //                    Log.i("Audio Path",path);
                    }while (audioCursor.moveToNext());
    
                }
    //            audioCursor.close();
            }
        }
    

提交回复
热议问题