Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
266 views
in Technique[技术] by (71.8m points)

android - Empty cursor from the MediaStore

I can't figure out why this cursor is empty in just this one particular device. but works on all other android devices. There are several audiofiles on the sdcard, and the stock mediaplayer can find and play these songs alright.

Cursor c = managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, new String[] { "distinct " + MediaStore.Audio.Media.ALBUM, MediaStore.Audio.Media.ARTIST, MediaStore.Audio.Media.ALBUM_KEY, MediaStore.Audio.Media.ALBUM_ID}, 
                null,
                null, 
                MediaStore.Audio.Media.ARTIST);

Both the ambling book player (I'm guessing they just loop through the folders and do their own id3 parsing) and the stock android music player find the music but I can't get anything from the mediastore. No ".nomedia" files are present, I have tried inserting new mp3 files to a new folder.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I have the same problem on a HTC Incredible and sadly DJC's answer didn't work for me. Both the EXTERNAL_CONTENT_URI and INTERNAL_CONTENT_URI didn't give me any images. After some digging I found that by using the following content URI, it did seem to work on the HTC Incredible.

Uri contenturi = Images.Media.getContentUri("phoneStorage");

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...