breautek commented on issue #568:
URL: 
https://github.com/apache/cordova-plugin-file/issues/568#issuecomment-1538306081

   > The folder I'm reading from is the Downloads folder of my Internal Storage.
   
   Are you sure you don't mean external storage?
   
   Android, Internal Storage refers to to the storage medium guaranteed to be 
on the device, it usually contains the app install, and the data partition is 
private to the app only.
   
   External Storage on the other hand may or may not be on the device. If the 
device has a physical removable storage, like an sdcard, then external storage 
will be that storage medium, but android also emulates external storage for 
devices that either don't have an attached storage medium or just plainly 
doesn't support one. The `Download/` directory is found on the External Storage 
medium. It may have a path such as `/sdcard/Download/`or 
`/storage/emulated/0/Download`.
   
   If the latter, then it's bit of a known issue unfortunately. As of API 30, 
Scoped Storage rules are fully enforced and there is a caveat on API 29 devices 
which I'll explain a bit later.
   
   **What is Scoped Storage**
   
   Scoped Storage is a privacy-focused storage system introduced by Android. It 
applies to External Storage medium and apps no longer have broad access to the 
external storage. `WRITE_EXTERNAL_STORAGE` no longer gives any permission, 
instead apps may freely read and write to the external storage. However they 
can only read and write to files that the app has created. If a file already 
exists but was created from from App A, then App B cannot read or write to that 
file using the Filesystem API.
   
   Natively to gain read & write access to these files, there is a 
_non-filesystem_ API called the `MediaStore` API. The owner of the file must 
implement a file provider service so it can grant permission to a third-party 
app trying to read or write to it. I want to emphasize that this API isn't 
filesystem-like at all so it will be difficult to treat it as such which is why 
it hasn't really been addressed or resolved in this plugin. For example, you 
cannot progrommatically list or view the contents of a directory (you can but 
it will be filtered to only files owned/created by your app) and instead the 
MediaStore will open the system's file picker and the user may choose the file 
they want to open.
   
   Additionally, specificially on API 29 devices which is when Scoped Storage 
was first introduced (but while targeting API 29, it could be opted out, which 
is not possible today if you intend to deploy to Google Play store). API 29 
devices **does not** have a File System bridge API into the scoped storage 
module. So using the Native `File` APIs to read/write files into external 
storage simply does not work and the **only** API available to do those actions 
is the previously mentioned `MediaStore` API.
   
   As a workaround for now, you'll need to use a 
[plugin](https://www.npmjs.com/search?q=cordova%20mediastore) that 
implements/exposes the MediaStore API. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.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