Java tutorial
//package com.java2s; import android.annotation.TargetApi; import android.net.Uri; import android.os.Build; import android.provider.DocumentsContract; public class Main { @TargetApi(Build.VERSION_CODES.KITKAT) private static String[] getMediaData(Uri uri) { final String docId = DocumentsContract.getDocumentId(uri); return docId.split(":"); } }