/** * 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