Android provides meta-information on media such as images, audio, and video through MediaStore providers. In other words, media meta-information is stored in a database and can be easily imported through queries. Please refer to the following code to print out the audio information.
Cursor cursor = null;
try {
cursor = getActivity().getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, null, null, null);
if (cursor != null) {
while (cursor.moveToNext()) {
String title = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.TITLE));
String artist = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.ARTIST));
String album = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.ALBUM));
long duration = cursor.getLong(cursor.getColumnIndex(MediaStore.Audio.Media.DURATION));
String path = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DATA));
...
}
}
} } finally {
if (cursor != null) {
cursor.close();
}
}
http://tkddlf4209.blog.me/220746210643
There's an example I made You have all the functions you asked.
© 2024 OneMinuteCode. All rights reserved.