本文介绍了MediaStore.Audio.Albums.ALBUM_ID无效的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法从MediaStore得到ALBUMID,我得-1从 getColumnIndex 。这是我的code:

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);
    }

由于某种原因, getColumnIndex(Audio.Albums.ALBUM_ID); 返回-1,没有人知道为什么会这样呢?专辑名称正常工作。

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

推荐答案

显然 _ID ALBUM_ID MediaStore.Audio.Albums.ALBUM_ID 。文档的MediaStore是非常糟糕的。

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

这篇关于MediaStore.Audio.Albums.ALBUM_ID无效的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 20:15