Here's what I would like to do in my app:
- allow user to select files and store paths to them inside a database
- display names of those files
- allow user to click on filename and open the chosen file
So I'd like to get real path to file and store it. The user will only be allowed to get files from internal/external storage so, as I assume, the real path will always exist. I've been looking for solutions and pretty much everyone asks only about images/audio/video and uses MediaStore in their solutions (and I, as of now, have no idea what this is, and I can get Uri without using it). I'd like a solution that would work with any type of file, if that's possible.
Here's how I'm getting Uri:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addFlags(FLAG_GRANT_READ_URI_PERMISSION);
intent.setType("*/*");
startActivityForResult(Intent.createChooser(intent, "Choose File"), 1);
and I'm storing the received information in onActivityResult
method.
So i get Uri and store it as a string which looks like, for example, content://com.android.providers.downloads.documents/document/4588
. How do I convert it to a real filepath?