ContentResolver musicResolver = getContentResolver();
Uri musicUri = android.provider.MediaStore.Audio.Media.INTERNAL_CONTENT_URI;
Cursor musicCursor = musicResolver.query(musicUri, null, null, null, null);
为什么我使用以上的代码获取不到我手机里面的音乐? 调试发现 musicResolver.query() 是这个函数有问题,然后进入这个函数后,发现内部的变量 cursor 为 null
,没有找到本地的音乐文件?那要用什么方法得到本地的音乐文件信息?
Maybe it’s a problem with my phone. Today I used my classmate’s code, and I was able to get the music on his phone. Then I downloaded the code to my
荣耀7
上就不行,我又把代码下到另外一个同学荣耀8
phone, but it didn’t work either. Sure enough, it’s a problem with the phone. It’s not a code problem, so I searched for related articles and finally found it:For now, it should be fine. If not, you can send me a private message.
Try using MediaStore.Audio.Media. EXTERNAL_CONTENT_URI directly