开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜