MauriceFrank commented on issue #585: URL: https://github.com/apache/cordova-plugin-file/issues/585#issuecomment-1651621368
> The MediaStore API has [CreateDeleteRequest](https://developer.android.com/reference/android/provider/MediaStore#createDeleteRequest(android.content.ContentResolver,%20java.util.Collection%3Candroid.net.Uri%3E)). Usage is described here: https://developer.android.com/training/data-storage/shared/media#remove-item Hey! Thanks! Do you also know if I can use the PermissionHelper in the file-plugin itself to request the following ?: MANAGE_EXTERNAL_STORAGE I tried in the file-plugin: private void getWritePermission(String rawArgs, int action, CallbackContext callbackContext) { int requestCode = pendingRequests.createRequest(rawArgs, action, callbackContext); // MANAGE_EXTERNAL_STORAGE on SDK33 if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { PermissionHelper.requestPermission(this, requestCode, Manifest.permission.MANAGE_EXTERNAL_STORAGE); } else { PermissionHelper.requestPermission(this, requestCode, Manifest.permission.WRITE_EXTERNAL_STORAGE); } } private boolean hasWritePermission() { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { return PermissionHelper.hasPermission(this, Manifest.permission.MANAGE_EXTERNAL_STORAGE); } else { return PermissionHelper.hasPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE); } } **and in the remove-action:** else if (action.equals("remove")) { threadhelper(new FileOp() { public void run(JSONArray args) throws JSONException, FileNotFoundException, IOException, NoModificationAllowedException, InvalidModificationException, MalformedURLException { String fname = args.getString(0); String nativeURL = resolveLocalFileSystemURI(fname).getString("nativeURL"); if (needPermission(nativeURL, WRITE)) { getWritePermission(rawArgs, ACTION_WRITE, callbackContext); } else { boolean success = remove(fname); if (success) { callbackContext.success(); } else { callbackContext.error(FileUtils.NO_MODIFICATION_ALLOWED_ERR); } } } }, rawArgs, callbackContext); **config.xml:** <config-file parent="/*" target="AndroidManifest.xml" xmlns:android="http://schemas.android.com/apk/res/android"> <uses-permission android:minSdkVersion="33" android:name="android.permission.MANAGE_EXTERNAL_STORAGE" /> </config-file> What did I forget? It throws "vendor.js:90891 ERROR Error: Uncaught (in promise): FileError: {"code":2,"message":"SECURITY_ERR"}" when triggering the remove-action. Expected would be the native popup/view which will ask the user to grant the .MANAGE_EXTERNAL_STORAGE. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
