使用以下代码列出所有相册详情,包括专辑名称,专辑,艺术家姓名和专辑封面图片
以下是我的代码,
public Map<String, String> getAlbumList(Context c) {
//setup map and cursor
Map<String, String> result = new HashMap<>();
String selection = MediaStore.Audio.Media.IS_MUSIC + " !=0";
final Cursor mCursor = c.getContentResolver().query(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
new String[] {MediaStore.Audio.Media.ALBUM,
MediaStore.Audio.Media.ARTIST,
MediaStore.Audio.Media.ALBUM_ID,
MediaStore.Audio.AlbumColumns.ALBUM_ART,}, selection, null,
"LOWER ("+MediaStore.Audio.Media.ALBUM + ") ASC");
int count = mCursor.getCount();
String[] mArtist = new String[count];
String[] mAlbum = new String[count];
String[] AlbumID = new String[count];
String[] imageId = new String[count];
int i = 0;
int j = 0;
if (mCursor.moveToFirst()) {
do {
mAlbum[i] = mCursor
.getString(mCursor
.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM));
mArtist[i] = mCursor.getString(mCursor
.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST));
AlbumID[i] = Long.toString(mCursor
.getLong(mCursor
.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM_ID)));
imageId[i] = mCursor.getString(mCursor
.getColumnIndexOrThrow(MediaStore.Audio.AlbumColumns.ALBUM_ART));
//checking for same previous value
if(result.containsValue(mAlbum[i])){
}else{
result.put("artist" + j, mArtist[i]);
result.put("album" + j, mAlbum[i]);
result.put("AlbumID" + j, AlbumID[i]);
result.put("AlbumID" + j, imageId[i]);
j = j + 1;
}
i = i + 1;
} while (mCursor.moveToNext());
}
mCursor.close();
return result;
}
但我收到以下错误消息
android.database.sqlite.SQLiteException:没有这样的专栏:album_art (代码1):,编译时:SELECT album,artist,album_id,album_art FROM audio WHERE(is_music!= 0)ORDER BY LOWER(专辑)ASC
我怎样才能解决这个问题?
我试图用专辑名称
获取albumimage