Android Question Real Path & Content Chooser

Marcos Alves

Well-Known Member
Licensed User
Longtime User
How can I get the real path of a downloaded file selected in a app with contentchooser? I already tested the code in https://www.b4x.com/android/forum/t...s-returned-from-contentchooser.39313/#content but I noticed that when getting a document from downloaded files folder it doesn't work!
Imagine the situation: an user selects some file in android. A file could be: pdf, doc, jpg, mp4/mpeg or png. Even using input/outputstream to copy the file to an known folder, I need to define an extension to target file. And without the real name, I don't know the extension.

Any suggestion?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
As written in that code snippet, it returns the path if it is available. There are many cases where the path will not be available. Each content provider can return any URI it likes.
The extension in the URI might be relevant and might not be relevant.
It will also behave in different ways between different devices and different OS versions.

The bottom line is that you should solve it in a different way. Ask the user which type of files they are looking for and limit ContentChooser based on that.
 
Upvote 0
Top