When writing something (such as a music player ), you need the MP3 list of SD card ~ START I use the column file again, but get the information of the file (singers, albums, pictures, length, etc.). ) is troublesome, so use this function directly ~
1 Private voidgetmusicpaths () {2 //3 //Get the music list4 //5cursor cursor = getcontentresolver (). Query (MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,NULL,NULL,NULL, MediaStore.Audio.Media.DEFAULT_SORT_ORDER);6 if(Cursor.movetofirst ()) {7 while(!Cursor.isafterlast ()) { 8 //Song number9 //int id = cursor.getint (cursor.getcolumnindexorthrow (mediastore.audio.media._id)); Ten //Song title OneString Tilte =cursor.getstring (Cursor.getcolumnindexorthrow (MediaStore.Audio.Media.TITLE)); A //Song's album Name: MediaStore.Audio.Media.ALBUM - //String album = cursor.getstring (Cursor.getcolumnindexorthrow (MediaStore.Audio.Media.ALBUM)); - //Song's singer name: MediaStore.Audio.Media.ARTIST theString artist =cursor.getstring (Cursor.getcolumnindexorthrow (MediaStore.Audio.Media.ARTIST)); - //path to the song file: MediaStore.Audio.Media.DATA -String URL =cursor.getstring (Cursor.getcolumnindexorthrow (MediaStore.Audio.Media.DATA)); - //Total duration of the song: MediaStore.Audio.Media.DURATION + //int duration = Cursor.getint (Cursor.getcolumnindexorthrow (MediaStore.Audio.Media.DURATION)); - //size of the song file: MediaStore.Audio.Media.SIZE + //Long size = Cursor.getlong (Cursor.getcolumnindexorthrow (MediaStore.Audio.Media.SIZE)); A Cursor.movetonext (); at } - } -}