java 从URI获取真实路径。字体:https://stackoverflow.com/questions/2789276/android-get-real-path-by-uri-getpath
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java 从URI获取真实路径。字体:https://stackoverflow.com/questions/2789276/android-get-real-path-by-uri-getpath相关的知识,希望对你有一定的参考价值。
private String getRealPathFromURI(Uri contentURI) {
String result;
Cursor cursor = mContext.getContentResolver().query(contentURI, null, null, null, null);
if (cursor == null) { // Source is Dropbox or other similar local file path
result = contentURI.getPath();
} else {
cursor.moveToFirst();
int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
result = cursor.getString(idx);
cursor.close();
}
return result;
}
以上是关于java 从URI获取真实路径。字体:https://stackoverflow.com/questions/2789276/android-get-real-path-by-uri-getpath的主要内容,如果未能解决你的问题,请参考以下文章