Search all audio files in the phone

Source: Internet
Author: User

The code is as follows

1  Public StaticList<music>Getallmusic (Context context) {2 musics.clear ();3         4Uri uri=MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;5         /**6 * Public String name;//song name7 Public String author;//singer8 Public String path;//Path
You can also get additional information9 */Tenstring[] Projection ={MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.ARTIST, One MediaStore.Audio.Media.DATA}; Acursor cursor = context.getcontentresolver (). Query (URI, projection,NULL,NULL,NULL); - while(Cursor.movetonext ()) { -Music m=Newmusic (); theM.author=cursor.getstring (1); -M.name=cursor.getstring (0); -M.path=cursor.getstring (2); - Musics.add (m); + } - + returnmusics; A}

The Bean class of music

1  Public class Music {2      Public String Path; 3      Public String name; 4      Public String author; 5     6 }

Search all audio files in the phone

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.