Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top