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 2021/08/27 18:09:41 UTC

[GitHub] [cordova-plugin-file] rmeyers4 edited a comment on issue #426: Storage updates in Android 11

rmeyers4 edited a comment on issue #426:
URL: https://github.com/apache/cordova-plugin-file/issues/426#issuecomment-907373767


   I work on an application that allows users to create directories in `externalRootDirectory` and save various files into these directories (QR codes, log files, csv files, etc). Users expect to be able to copy files off of the tablet when using a Windows computer to explore the tablet file system.
   
   After spending a bunch of time trying to migrate this functionality to allow files to be saved to `externalApplicationStorageDirectory`, I discovered a potentially much simpler solution. From my testing so far, applications using this plugin and opting in to Scoped Storage can still create directories and write files to the `Documents` folder in `externalRootDirectory`.
   
   I tested this on API 29 with Scoped Storage enabled on an Android 11 tablet by going to Developer Options -> App Compatibility Changes -> <my application> and turning on  `FORCE_ENABLED_SCOPED_STORAGE` and
    all of the "Enabled for targetSdkVersion > 29 features" except for `NATIVE_HEAP_POINTER_TAGGING`. I have no idea why this flag prevents files from being created, but luckily it is not (currently) required for apps targeting API 30.
   
   I then targeted API 30 and added the following to `config.xml`:
   ```
     <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
       <application android:allowNativeHeapPointerTagging="false"/>
     </edit-config>
   
   ```
   https://developer.android.com/guide/topics/manifest/application-element#allowNativeHeapPointerTagging
   
   My application seems to function as it did without scoped storage as long as I prefix my paths with `Documents/` when targeting API 29 and API 30.  We will need to train our users to expect files to be in this location, but (so far) this seems much simpler than trying to use app-specific storage.
   
   I hope this helps someone else, or hope someone tells me why I'm wrong!
   


-- 
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