You can use content provider for this.
Hope this code may help you to start up.
final Cursor mCursor = getContentResolver().query(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
new String[] { MediaStore.Audio.Media.DISPLAY_NAME,
MediaStore.Audio.Media.DATA,
MediaStore.Audio.Media.ARTIST,
MediaStore.Audio.Media.ALBUM_ID }, null, null,
"LOWER(" + MediaStore.Audio.Media.TITLE + ") ASC");
int count = mCursor.getCount();
String[] songs = new String[count];
if (mCursor.moveToFirst()) {
do {
String songname = mCursor
.getString(mCursor
.getColumnIndexOrThrow(MediaStore.Audio.Media.DISPLAY_NAME));
String sonpath = mCursor.getString(mCursor
.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA));
String artistname = mCursor.getString(mCursor
.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST));
String albumid = mCursor
.getString(mCursor
.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM_ID));
} while (mCursor.moveToNext());
Constant.sdCardmusic = allsongs;
}
mCursor.close();
}
If you want to get album picture then you can pass album id getting from above code into below method:
private Bitmap getArtistImage(String albumid) {
Bitmap artwork = null;
try {
Uri sArtworkUri = Uri
.parse("content://media/external/audio/albumart");
Uri uri = ContentUris.withAppendedId(sArtworkUri,
Long.valueOf(albumid));
ContentResolver res = mContext.getContentResolver();
InputStream in = res.openInputStream(uri);
artwork = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Exception", e.toString());
}
return artwork;
}