-
Notifications
You must be signed in to change notification settings - Fork 692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not getting the absolute path for any file in storage. #411
Comments
Hi @naman-jn, this have been explained multiple times and unfortunately that’s how Android team want (see #398 answer for example). Accessing absolute paths from anywhere on the device, being it a SD card or internal storage, may result in undesired effects as sometimes paths just can’t be retrieved at all. Since scoped storage was introduced with Android 10, this gets even worse and you’d not be happy to have your users not having reliable ways to pick the files, this is, some devices could actually pick whereas others don’t. There are 2 main approaches currently that Android docs suggest:
TL;DR: after picking the file the first time, just move it to your app storage scope and use it from there onwards (you can use Have in mind that currently file_picker is optimised to the point where if you pick twice the same file (with the same name) you’ll be probably picking the previous cached file, as it only will be cached the first time is picked. However, this issue give an idea of adding another flag property when picking which is making the files persistent or not after picking, which would prevent this additional step for those that actually want it. |
Thanks !! Well is there a way where I can get the absolute path as I need to make changes to the real file from my app? |
@naman-jn you can move the file like I said to your apps directory after picking or, as a last resource, you can use any version of file_picker below 2.0.0, which does exactly what you’re looking for, picking the the real absolute path, but be aware of what I’ve mentioned before. |
@miguelpruivo
I am facing the same issue even in the latest version. For any file from the storage even using default file explorer a temporary file is being created in my app folder and this file is being returned
Thanks for the response. In my case, I am trying to load a file created by a third party game and stored in the phone's Documents folder (on Android). This is the path to the file on my phone:
/storage/emulated/0/Documents/Sports Interactive/Football Manager 2019 Mobile/normal/games/fm_save4.dat
It's not a remote URI, it's on the phone, but file_picker is caching it to:
/data/user/0/com.example.fmm_app/cache/fm_save4.dat
I want to be able to store the direct path, so when the user plays the game and the file changes, they can reload it through my app without needing to go through file_picker again (as it's relatively slower and more clicks etc). The cached version is out of date as soon as they play the game again, so is useless.
If I hard code in the direct path, I can open file, so it seems I have permissions to access it even though it's in a Documents folder belonging to another app. Is there anyway file_picker can provide this path? Is there some sort of bug preventing it? Or more likely, something I'm missing? Thanks!
Originally posted by @Stephen-Cronin in #40 (comment)
The text was updated successfully, but these errors were encountered: