im using the following code to list all album details including album name, albumid, artistname and album cover image
Following is my code,
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;
}
But im getting the following error message
android.database.sqlite.SQLiteException: no such column: album_art (code 1): , while compiling: SELECT album, artist, album_id, album_art FROM audio WHERE (is_music !=0) ORDER BY LOWER (album) ASC
How can I be able to sort this out?
Im trying to get albumimage with album name