开发者

Loading a Cursor in Android with info from the MediaStore.Audio provider

开发者 https://www.devze.com 2023-02-20 22:02 出处:网络
I\'m trying to load some parameters from the default Content Provider MediaStore.Audio into a Cursor but when debugging the code it stops running just in the managedQuery. The method just don\'t run f

I'm trying to load some parameters from the default Content Provider MediaStore.Audio into a Cursor but when debugging the code it stops running just in the managedQuery. The method just don't run further than the managedQuery. Here is the code with the query:

Uri exAudioUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;

String[] projection =开发者_StackOverflow中文版 new String[] {
    MediaStore.Audio.Media._ID,
    MediaStore.Audio.Media.DISPLAY_NAME,
    MediaStore.Audio.Media.DATA,
    MediaStore.Audio.Media._COUNT,
};
Cursor cExAudio = managedQuery(exAudioUri, projection, null, null, MediaStore.Audio.Media.DISPLAY_NAME + " DESC");

I've read in the documentation that this method is deprecated and shouldn't be used but is the only option I have with the API Level I'm using.


If you remove MediaStore.Audio.Media._COUNT from String[] projection should solve your problem.

Basically there is no column called "_COUNT"

String[] projection = new String[] {
    MediaStore.Audio.Media._ID,
    MediaStore.Audio.Media.DISPLAY_NAME,
    MediaStore.Audio.Media.DATA
};
0

精彩评论

暂无评论...
验证码 换一张
取 消