Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private fun loadStorageData() {
- val selection = MediaStore.Audio.Media.IS_MUSIC + " != 0"
- val projection = arrayOf(
- MediaStore.Audio.Media._ID,
- MediaStore.Audio.Media.TITLE,
- MediaStore.Audio.Media.ARTIST,
- MediaStore.Audio.Media.ALBUM,
- MediaStore.Audio.Media.DATA,
- MediaStore.Audio.Media.DURATION
- )
- contentResolver.query(
- MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
- projection,
- selection,
- null,
- null
- ).use { cursor ->
- if (cursor != null) {
- while (cursor.moveToNext()) {
- mainActivityViewModel.allTracksLiveData.value!!.add(
- Track(
- cursor.getLong(0),
- cursor.getString(1),
- cursor.getString(2),
- cursor.getString(3),
- cursor.getString(4),
- cursor.getLong(5)
- )
- )
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement