I'm letting users pick a file from their device using:
registerForActivityResult(ActivityResultContracts.GetContent()) { uri: Uri? -> ... }
I want to find out what is the name of the file they've picked. How can I retrieve the file name?
CodePudding user response:
You can get a display name via DocumentFile
:
DocumentFile.fromSingleUri(uri).name
What the "display name" is will be up to the DocumentsProvider
that the user is using. If the user is working with a filesystem-based provider, the display name probably is a filename.