android 选择图片后获取真实的图片路径
作者:
小相柳 | 来源:发表于
2020-01-15 09:37 被阅读0次private String getRealImageFilePath(final Context context, final Uri uri) {
String mRealPath = "";
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = context.getContentResolver().query(uri, filePathColumn, null, null, null);
if (cursor != null && !cursor.isClosed()) {
if (cursor.getCount() > 0 && cursor.moveToFirst()) {
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
if (columnIndex > -1) {
mRealPath = cursor.getString(columnIndex);
}
if (!cursor.isClosed()) {
cursor.close();
}
return mRealPath;
}
}
return "";
}
本文标题:android 选择图片后获取真实的图片路径
本文链接:https://www.haomeiwen.com/subject/afazactx.html
网友评论