Mobile Audio 10--Music list

Source: Internet
Author: User

/** * Get data from local SDcard *//1. Traverse sdcard, suffix *//2. Get video from content provider *//3. If the system is 6.0, dynamically get read SDcard permissions */private void Getdatafromloca                L () {new Thread () {@Overridepublic void run () {super.run ();//ISGRANTEXTERNALRW (Activity) context);// Systemclock.sleep (+); mediaitems = new arraylist<> (); Contentresolver resolver = Context.getcontentresolver (); Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; String[] Objs = {mediastore.audio.media.display_name,//video file in SDcard name mediastore.audio.media.duration,// Total video Length mediastore.audio.media.size,//The file size of the video mediastore.audio.media.data,//the absolute address of the video mediastore.audio.media.artist,/ /singer of the song}; cursor cursor = resolver.query (URI, OBJS, NULL, NULL, NULL), if (cursor! = NULL) {while (Cursor.movetonext ()) {Mediaitem Medi AItem = new Mediaitem (); Mediaitems.add (Mediaitem);//write on the above string name = Cursor.getstring (0);//The name of the video Mediaitem.setname ( name); Long Duration = Cursor.getlong (1);//duration of the video mediaitem.setduration (duration); Long size = Cursor.getlong (2);// The file size of the videoMediaitem.setsize (size); String data = cursor.getstring (3);//video playback address mediaitem.setdata (data); String artist = cursor.getstring (4);//artist mediaitem.setartist (artist);} Cursor.close ();} Handler Send message Handler.sendemptymessage (10);}}. Start ();}

  

Mobile Audio 10--Music list

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.