if(Build.VERSION.SDK_INT >=19){
if(DocumentsContract.isDocumentUri(this,uri)){
String totalId=DocumentsContract.getDocumentId(uri)
if("com.android.providers.media.documents".equals(uri.getAuthority())){
String id=totalId.split(":")[1]
String selection= MediaStore.Images.Media._ID+"="+id
path=doTranslate(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,selection)
}else if("com.android.providers.downloads.documents".equals(uri.getAuthority())){
Uri contentUri= ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),Long.valueOf(totalId))
path=doTranslate(contentUri,null)
}
}else if("content".equalsIgnoreCase(uri.getScheme())){
path=doTranslate(uri,null)
}else if("file".equalsIgnoreCase(uri.getScheme())){
path=uri.getPath()
}
}else{
path=doTranslate(uri,null)
}
private String doTranslate(Uri uri,String selection){
String thePath=null;
Cursor cursor=getContentResolver().query(uri,null,selection,null,null);
if(cursor!=null){
if(cursor.moveToFirst()){
thePath=cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));
}
cursor.close();
}
return thePath;
}