You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2022/05/13 13:30:13 UTC

[GitHub] [cordova-plugin-file] breautek commented on issue #408: Platform android@9.0.0 running on Android 10 : getFile produces INVALID_MODIFICATION_ERR - Error code 9.

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

   The [requestLegacyExternalStorage](https://developer.android.com/about/versions/11/privacy/storage#scoped-storage) flag is an API 29 only flag. It was added to make API 29 revert back to the old filesystem as it worked in API 28. Without it, API 29 will use the newer restricted filesystem. API 30 or later ignores this flag.
   
   > Issue: Getting {"code": 9} as error when trying to create a new file in the cordova.file.externalRootDirectory.
   
   The `externalRootDirectory` directory is no longer a writable path with the Android's new filesystem. Google doesn't explicitly say which paths are no longer accessible, but it does [vaguely](https://developer.android.com/about/versions/11/privacy/storage#migrate-data-for-scoped-storage) say that some paths that used to be writable will no longer be accessible.
   
   > If your app uses the legacy storage model and previously targeted Android 10 or lower, **you might be storing data in a directory that your app cannot access when the [scoped storage](https://developer.android.com/training/data-storage#scoped-storage) model is enabled**...
   
   In my testing, reading & writing of the root external directory is no longer allowed. You can access existing subdirectories, such as `Pictures/` or `Downloads/`. You can read from these directories if you have `READ_EXTERNAL_STORAGE` permission granted, or if your app is the creator of the content. You can write to these directories without any additional permissions (`WRITE_EXTERNAL_STORAGE` permission is now obsolete).
   
   I believe creation of new directories is also forbidden, except for your application's external data directory.
   
   My best advice is to evaluate whether you actually need external storage. Are you trying to make your files shareable between apps? If not, then perhaps you should be using the internal storage directories instead, e.g. `cordova.file.dataDirectory`. It will make your life significantly easier. Otherwise, you may need to do refactoring to ensure you're operating within the constraints of scoped storage.
   
   I've already explained this a few times in the past on this thread, so I'll be locking this thread. It's an older thread, if you continue having an issue which you believe is a bug in this plugin, I suggest opening a new issue with more modern/up-to-date information.


-- 
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-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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