public String getPAth(Uri uri) {
String path = null;
if (!TextUtils.isEmpty(uri.getAuthority())) {
Cursor cursor = getContentResolver().query(uri,
new String[]{MediaStore.Images.Media.DATA}, null, null, null);
if (null == cursor) {
Toast.makeText(this, "图片没找到", Toast.LENGTH_SHORT).show();
return null;
}
cursor.moveToFirst();
path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));
cursor.close();
} else {
path = uri.getPath();
}
return path;
}
版权声明:本文为jsupoker原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。