I want to access the music library in Android phone (not sdcard) & show it in list. I want to get all info related to each file like duration, artist etc. How would I do that programmatically?
private void musics(){
Uri uri = MediaStore.Audio.Media.INTERNAL_CONTENT_URI;
ContentResolver cr = getContentResolver();
String[] columns = {MediaStore.Audio.Media.DISPLAY_NAME};//add which column you need here
Cursor cursor = cr.query(uri, columns, null, null, null);
if(cursor == null){
return;
}
if(cursor.getCount() > 0){
cursor.moveToFirst();
do{
//read your information here
String artist = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DISPLAY_NAME));
}while(cursor.moveToNext());
}
cursor.close();
}