-
-
Save nikunjparadva/50a12dba5c72ed86cfed4a1c04d04554 to your computer and use it in GitHub Desktop.
Android: List all music files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Retrieve a list of Music files currently listed in the Media store DB via URI. | |
//Some audio may be explicitly marked as not being music | |
String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0"; | |
String[] projection = { | |
MediaStore.Audio.Media._ID, | |
MediaStore.Audio.Media.ARTIST, | |
MediaStore.Audio.Media.TITLE, | |
MediaStore.Audio.Media.DATA, | |
MediaStore.Audio.Media.DISPLAY_NAME, | |
MediaStore.Audio.Media.DURATION | |
}; | |
cursor = this.managedQuery( | |
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, | |
projection, | |
selection, | |
null, | |
null); | |
private List<String> songs = new ArrayList<String>(); | |
while(cursor.moveToNext()){ | |
songs.add(cursor.getString(0) + "||" + cursor.getString(1) + "||" + cursor.getString(2) + "||" + cursor.getString(3) + "||" + cursor.getString(4) + "||" + cursor.getString(5)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment