由网友(妞妞児っ)分享简介:我无法从MediaStore得到ALBUMID,我得-1从 getColumnIndex 。这是我的code:I can't get the albumID from MediaStore, i get -1 from getColumnIndex. Here is my code:Cursor cursor = m...
我无法从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.
相关推荐
最新文章