简体   繁体   中英

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 = 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
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM