Android MediaStore.Audio.Playlist Query Is Empty
I'm trying to do something relatively simple: fetch a list of Music playlists that were created in the Android 'Music Player' application (the stock app, com.android.music, not a third party app) and display it in my own application. I'm querying MediaStore.Audio.Playlists. My code looks something like this:
String[] projection = { MediaStore.Audio.Playlists._ID, MediaStore.Audio.Playlists.NAME };
Cusor cursor = getContentResolver().query(
MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
projection,
null,
null,
null);
if (cursor.getCount() > 0) {
cursor.moveToFirst();
do {
// do stuff with each playlist
} while (cursor.moveToNext());
}
cursor.close();
This code works fine in Android 2.3.4. However, in Android 2.2 and 2.1, with older versions of the Music Player (1.1.1 and 1), this query returns an empty result set.
Why is this happening? Are playlists not stored in the same location in older versions of the 'Music Player' app? I've tried to diff various playlist-related files from the source code of the 'Music Player' app (available here) but I didn't find anything helpful. Even the older versions of the Music Play开发者_高级运维er seem to manipulate MediaStore.Audio.Playlists.
What am I missing here?
精彩评论