This question already has answers here:
Convert Uri to String and String to Uri
(5个答案)
去年关闭。
如何在Kotlin中将字符串转换为Uri而不是Java(Android)?
Uri_string = ???;
要么
(5个答案)
去年关闭。
如何在Kotlin中将字符串转换为Uri而不是Java(Android)?
val Uri_string = "/sdcard/example.jpg"
Uri_string = ???;
最佳答案
val uri = Uri.parse(Uri_string)
要么
val fileName = "example.jpg"
val path = "${Environment.getExternalStorageDirectory()}/$fileName"
val file = File(path);
val uri = Uri.fromFile(file);