MediaStore.Audio.Albums.ALBUM_ID invalid column

久未见 提交于 2019-12-02 03:25:57

问题


I can't get the albumID from MediaStore, i get -1 from getColumnIndex. Here is my code:

    Cursor cursor = mContext.getContentResolver().query(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI,
                    null, null, null, null);
    if (cursor.moveToFirst() == false)
    {
            //no rows empty cursor
    }
    int albumColumnIndex = cursor.getColumnIndex(Audio.Albums.ALBUM);
    int albumidColumnIndex = cursor.getColumnIndex(Audio.Albums.ALBUM_ID);
    String album = cursor.getString(albumColumnIndex);
    int id = cursor.getInt(albumidColumnIndex);

    while(cursor.moveToNext())
    {
        album = cursor.getString(albumColumnIndex);
        id = cursor.getInt(albumidColumnIndex);
    }

For some reason getColumnIndex(Audio.Albums.ALBUM_ID); returns -1, does anyone know why could that be? Album name works fine.


回答1:


Apparently _ID is ALBUM_ID for MediaStore.Audio.Albums.ALBUM_ID. Docs for MediaStore are really bad.



来源:https://stackoverflow.com/questions/21996228/mediastore-audio-albums-album-id-invalid-column

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