Querying Google Play Music database in Android

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 20:57:00

I know this thread is old, but I have been grappling with this problem too.

Google Play Music exposes its playlists at this non-standard Content URI

// list all playlists with their ID and Name
Cursor cursor = getContentResolver().query(
    "content://com.google.android.music.MusicContent/playlists", 
    new String[] {"_id", "playlist_name" }, 
    null, null, null);

The Google Play Music content provider uses the following column names

  • isAllLocal
  • playlist_owner_name
  • hasLocal
  • hasRemote
  • hasAny
  • KeepOnId
  • playlist_art_url
  • playlist_share_token
  • _id
  • _count
  • playlist_owner_profile_photo_url
  • keeponSongCount
  • playlist_description
  • playlist_type
  • playlist_id
  • keeponDownloadedSongCount
  • playlist_name

I would have never figured this out without this really helpful app Content Provider Helper

Try this.

String[] proj = {MediaStore.Audio.AudioColumns.TITLE,MediaStore.Audio.Media.ARTIST,MediaStore.Audio.Media._ID};
Uri gMusicUri = Uri.parse("content://com.google.android.music.MusicContent/audio");
Cursor cursor = getApplicationContext().getContentResolver()
            .query(gMusicUri,
                    proj, null, null, null);

Î tried querying the ContenProvider like you can see it in Logcat when you Start the google Music app:

getContentResolver().query(Uri.parse("content://com.google.android.music.MusicContent/playlists"), null, null, null, null);

but I got no result :-( maybe Im doing s.th. wrong, didnt work much with contentproviders before, or maybe the contentprovider is not public for other apps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!