-
Notifications
You must be signed in to change notification settings - Fork 3
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
Full pah of Download directory #2
Comments
Hi João - It looks like this might require a new method (and some thought on my part). Android has deprecated the Environment.GetExternalPublicStorageDirectory() that returned the entire path, to tighten security (see https://developer.android.com/reference/android/os/Environment#getExternalStorageDirectory()). |
Hi Erik, Yes, I saw that deprecation after API 29. But where should I now
store app generated files which the user may access with File Explorer (for
example pdf files)?
|
Hi João - for now, I've updated the plugin with access to the getExternalStorageDirectory() call (this is in v.1.1.0 of the plugin, but it might take some time for npm to refresh properly. You can always pull down the plugin directly if needed). Longer term, I'm not sure what the solution is. You could concatenate to build the path like you've been doing above, or use some sort of fallback tree like we're doing in Adapt It Mobile (see ~line 3250 of DocumentViews.js here: https://github.com/adapt-it/adapt-it-mobile/blob/master/www/js/views/DocumentViews.js -- I'm just going until I find a usable directory, and then creating a subdirectory under that to store our exported files). I'm not seeing in the Android docs how (or if) we're supposed to be using shared folders like Downloads. Everything seems to be referring to documents created by a specific app and only to be used for that app. I think, though, that File Explorer should be able to find app-specific files under cordova.file.externalRootDirectory. I can't recall having a problem finding files once they were exported. |
Looks like npm refreshed with the 1.1.0 release of cordova-plugin-env. I'm marking this issue closed for the short term, because the getExternalStoragePublicDirectory() method does return a full path to the specified directory; albeit with an API that has an expiration date. :-/ |
I should add -- if you do come across a future-proof way of getting at the full path for these directories, I'd be glad to fold in a pull request. Thanks for reporting the issue! |
Thanks Erik. Do kindly check also this thread from cordova-plugin-file, if you haven't seen yet: Since Android does not allow access to shared folders in API 30, I think in cordova they might probably need some sort of file picker, as they recommend in the docs of android. |
Wow. It'll be interesting to see how they implement the changes! |
Is your feature request related to a problem? Please describe.
I want to have the full path of Downloads directory
Describe the solution you'd like
a full path of a directory
Describe alternatives you've considered
I tried this as described in the docs:
The problem is that
path
returns onlyDownload
and not the full path.I'm doing
cordova.file.externalRootDirectory + path
but not sure if this is correctAdditional context
cordova info
Output from my cordova infoThe text was updated successfully, but these errors were encountered: