I have downloaded a file, and saved in a directory
cordova.file.externalRootDirectory+'appName/'+file;
and I am using cordova-plugin-file-opener2 plugin to access that file.
But I am getting following error in few phones:
ava.io.FileNotFoundException: /storage/emulated/0/appName/7cc45cf629027499_05750_BG.jpg (Permission denied)
I have checked that file exists at this location.
This depend on the OS, on the new OS version like Nouget you must have read and write permission . Since Android 6.0, the Android permissions checking mechanism has been changed. To make it easier, just use https://github.com/NeoLSN/cordova-plugin-android-permission plugin.
on android I just used the following directory and it worked like a charm:
cordova.file.externalApplicationStorageDirectory
information source
By the way, the FileNotFoundException also occurs when you have permission issues (at least in this plugin).
Related
Hello everyone
Environment :
Android 11
react-native 0.68.5
react-native-fs 2.20.0
Need:
Save files persistent to the application (if I uninstall the application the files need to persist). If I reinstall the application I need to be able to manipulate these files again. I uploaded the files in the download folder with RNFS.DownloadDirectoryPath so that they are not deleted when the application is uninstalled but the files are public and can be downloaded to another location if needed.
Error:
Everything works perfectly until I uninstall and reinstall the application. As soon as I want to manipulate an existing file in my /storage/emulated/0/Download/AppName/...
I encounter the following error when I want to move file :
Error: ENOENT: open failed: EACCES (Permission denied), open '/storage/emulated/0/Download/AppName/...
I encounter the following error when I want to download file :
Error: ENOENT: no such file or directory, open '/storage/emulated/0/Download
Before manipulating a file I make sure I have the :
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE
PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE
My build.gradle :
buildToolsVersion = "31.0.0"
minSdkVersion = 30
compileSdkVersion = 31
targetSdkVersion = 31
My manifest :
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
....
android:requestLegacyExternalStorage="true"
android:preserveLegacyExternalStorage="true"
...
A big thank you to the people who will take their time to help me
To try to solve the problem I added this line in my manifest :
android:preserveLegacyExternalStorage="true"
and I changed the minSdkVersion in my build.gradle from 21 to 30.
I have the impression that the rights belonged to the application as if by reinstalling the application it lost its rights.
You did not tell it but this happens to you on Android 11+ devices.
On Android 11+ an app has only access to the files it created itself and media files in public directories.
After reinstall an app is considered a different app.
Use Storage Access Framework ACTION_OPEN_DOCUMENT to let the user pick the files.
I want user permission to read and write on external storage. I have used "Permission Handler" dependency v5.0.1+1 but failed to get storage permission. I have declared Read n Write storage permission in android manifest and have set minSdk to 23, target and compile sdk set to 30 in build file.
Error Encounter:
MissingPluginException(No implementation found for method requestPermissions on channel flutter.baseflow.com/permissions/method
You're getting MissingPluginException because platform-specific code is not generated
Just run flutter clean command and rebuild the app
I've my app as system-priv and build along with my AOSP code. now my app needs to copy the tombstone folder which is under /data/tombstones to /sdcard.
thanks in advance
I got it worked.
There are 2 parts
i) You've to register tombstones path using FileObserver, so whenever new tombstone created you'll get the callback.
ii) Your app should have the permission to read this path otherwise you'll get an avc denied due to SELinux. So add permission to system_app.te file of sepolicy.
I'm trying to open files from C in my Android app/library. This did work at some point but stopped working after changing several things that seem completely irrelevant, and don't run until after this error occurs.
I am using the following function in C: *ppFile = fopen(fullUncFilePathAndName, "r+b"); and then again with permissions "w+b"
After each of these calls, errno = 13 (Permission Denied).
The file path is /data/data/{appFolder}/files/{filename} (got from Context.getFilesDir().getAbsolutePath(), and the working directory according to the C functions is "/". This is on internal storage, but I added the permission WRITE_EXTERNAL_STORAGE just because I had nothing else to do.
Can anyone think why reading or writing to existing and non-existent files in internal storage from an NDK library would fail with permission errors?
This problem solved itself in the best worst way possible. I deleted my app's data folder in the file browser, and then at the next build the app created its files without a hitch.
You could also clean the project and recompile from scratch.
I'm trying to create zip file inside my application files folder (/data/data/myapp/files) but getting "failed to create zip file | open failed: EACCES (Permission denied)" error message every time. As I can see using android debug bridge, my files folder have "rwx------" permissions and "root" owner and group. I think this is the problem but I can't understand why my folder have this owner and group?
Make sure you :
have rooted your device
have the rights to write on the internal storage
are not trying to test it with the usb storage enabled on your phone
added the permission <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" /> in your manifest
I solved the problem by manually setting right owner, group and permissions on my application files folder (using chmod, chown and chgrp commands). It does not seem like an answer, because it is still unclear why this folder got wrong permissions but unfortunately I don't have enough time to understand where problem is.