ContentResolver - how to get file name from Uri

后端 未结 7 532
误落风尘
误落风尘 2020-12-30 03:38

I call startActivityForResult with Intent ACTION_GET_CONTENT. Some app returns me data with this Uri:

content://media/external/images/media/18122

I

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-30 03:51

    To get filename, you can use new DocumentFile format.

    DocumentFile documentFile = DocumentFile.fromSingleUri(this, data.getdata());
    String fileName = documentFile.getName();
    

提交回复
热议问题