簡體   English   中英

如何從 android 餅圖中的 content:// 方案中獲取文件 object?

[英]How to get a file object from the content:// scheme in android pie?

我有這段代碼,它將圖像文件的路徑存儲在本地數據庫中,就像從運行 Android Pie 的設備的內部存儲中選擇圖像時返回的“content://media/external/images/media/25” .

現在,當我嘗試從上述內容路徑創建文件 object 時,它會拋出 FileNotFoundException。

val imagePath = URL("content://media/external/images/media/25")
val imageFile = File(imagePath)

任何幫助表示贊賞。

嘗試使用 ContentUris

Uri contentUri = ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,id);
File file =new File(contentUri)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM