Mobile phone audio and video 10-music list, audio and video 10-list
/*** Get data from local sdcard * // 1. traverse sdcard with the suffix * // 2. obtain the video from the content provider * // 3. if it is a 6.0 system, dynamically obtain the permission to read sdcard */private void getDataFromLocal () {new Thread () {@ Overridepublic void run () {super. run (); // isGrantExternalRW (Activity) context); // SystemClock. sleep (2000); mediaItems = new ArrayList <> (); ContentResolver resolver = context. getContentResolver (); Uri uri = MediaStore. audio. media. EXTERNAL_CONTENT_URI; String [] objs = {MediaStore. audio. media. DISPLAY_NAME, // The name of the video file in the sdcard MediaStore. audio. media. DURATION, // total video DURATION MediaStore. audio. media. SIZE, // the video file SIZE MediaStore. audio. media. DATA, // The absolute video address MediaStore. audio. media. ARTIST, // Song ARTIST}; Cursor cursor = resolver. query (uri, objs, null); if (cursor! = Null) {while (cursor. moveToNext () {MediaItem mediaItem = new MediaItem (); mediaItems. add (mediaItem); // String name = cursor. getString (0); // The video name mediaItem. setName (name); long duration = cursor. getLong (1); // The video length mediaItem. setDuration (duration); long size = cursor. getLong (2); // the video file size mediaItem. setSize (size); String data = cursor. getString (3); // The video playback address mediaItem. setData (data); String artist = cursor. getString (4); // artist mediaItem. setArtist (artist);} cursor. close ();} // Handler sends a message to handler. sendEmptyMessage (10 );}}. start ();}