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;
}
Android:通过Uri获取图片文件真实路径
猜你喜欢
转载自blog.csdn.net/jsupoker/article/details/97936024
今日推荐
周排行