簡體   English   中英

使用Android中的下載管理器獲取下載文件的文件名

[英]Get file name of download file using download manager in android

眾所周知, DownloadManager.COLUMN_LOCAL_FILENAME已從api級別24 棄用 ,要獲取從下載管理器google下載的文件的文件名,谷歌說使用ContentResolver.openFileDescriptor()訪問文件名

誰能建議我如何使用ContentResolver.openFileDescriptor()訪問文件名

您無法通過openFileDescriptor()訪問文件名。 由於您是請求下載的人,因此您已經知道文件名是什么。

我沒有使用ContentResolver.openFileDescriptor()。

要檢索下載文件的舊的絕對路徑,只需:

String absolutePath =  Uri.parse(cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI))).getPath();

而且當然 :

File file = new File(absolutePath);

暫無
暫無

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

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