Android Uri转File path路径,Kotlin
/**
* URI转化为file path路径
*/
private fun getFilePathFromURI(context: Context, contentURI: Uri): String? {
val result: String?
var cursor: Cursor? = null
try {
cursor = context.contentResolver.query(contentURI, null, null, null, null)
} catch (e: Exception) {
e.printStackTrace()
}
if (cursor == null) {
result = contentURI.path
} else {
cursor.moveToFirst()
val idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA)
result = cursor.getString(idx)
cursor.close()
}
return result
}
Android 13手机图片存储File路径转Uri,Java_android file 转uri-CSDN博客文章浏览阅读682次。android根据图片资源的drawable id转化为Uri,java_zhangphil的博客-CSDN博客。android根据图片资源的drawable id转化为Uri的工具方法。Android 13手机图片存储File路径转Uri,Java。_android file 转urihttps://blog.csdn.net/zhangphil/article/details/129640812android根据图片资源的drawable id转化为Uri,java_android drawable 转uri-CSDN博客文章浏览阅读649次。android根据图片资源的drawable id转化为Uri的工具方法。_android drawable 转urihttps://blog.csdn.net/zhangphil/article/details/129431755
Android4.4以上版本Uri content转换成File文件路径_android content 转 file-CSDN博客文章浏览阅读4.4k次,点赞2次,收藏8次。public static String getFilePathByUri(Context context, Uri uri) { String path = null; // 以 file:// 开头的 if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())) { ..._android content 转 filehttps://blog.csdn.net/zhangphil/article/details/87859320