GitHub user breautek edited a comment on the discussion: How do I open a saved 
PDF file on my Android device ?

Kind of outside my expertise so I can't really explain how very well.

But the `dataDirectory` is app-private. It doesn't mean you can't share the 
files but other apps can't just read it. There's probably an android intent 
(which you'll need to find a plugin that exposes an API to use) for sharing 
files. This is typical for apps that want to have a share button to bring up 
some UI to let the user select which app they want to share the file with (e.g. 
email client, the clipboard, facebook, so on....)

The external storage partition apps also has slightly more flexibility, where 
you could store the file inside `Documents` folder but the file plugin cannot 
write to this directory. Modern Android (API 29+) limits the ability for the 
File APIs to read/write documents onto the external storage. Instead you must 
use a Media Store API, which there are also third-party plugins for. Once 
written to external storage, other apps can use file picking APIs where the 
user should be able to see and select a file to be opened in another app). 
Depending on your use case, this might be fine.

If you can't find a plugin that exposes file sharing and want to tackle it 
yourself by creating your own plugin, then 
https://developer.android.com/training/secure-file-sharing will probably be a 
start to understand the android API and 
https://cordova.apache.org/docs/en/12.x/guide/hybrid/plugins/index.html for 
creating a cordova plugin.

> or "share" using the physical URL of the generated file

To be clear on this, `file://` uris are definitely not shareable, especially if 
you're using internal storage (like the `dataDirectory`). External storage 
paths are shareable but the apps will need to have additional permissions, so 
it's not ideal and likely won't work the way you'd expect.

The native way to share files is to produce a `content://` uri for it, which 
can be shared with other apps. This is generally handled by the intent system.

GitHub link: 
https://github.com/apache/cordova/discussions/510#discussioncomment-11338237

----
This is an automatically sent email for issues@cordova.apache.org.
To unsubscribe, please send an email to: issues-unsubscr...@cordova.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to