Hello, sorry for a question but I can’t believe this thing… With my app I would like to write a very banal image file on the external memory in Android so that it is then visible in the phone gallery. The documentation reads this
The external storage directory On iOS will use the Documents directory On Android it is the primary external/shared storage directory. It is not accessible on Android 10 unless the app enables legacy external storage by adding android:requestLegacyExternalStorage=“true” in the application tag in AndroidManifest.xml. It is not accessible on Android 11 or later.
I mean… I’m full of apps in my phone that write to external storage folder and files, yet capacitor can’t… But how the heck is that possible? Or am I doing it wrong? Thank you
What I was doing is using the cordova-file-opener plugin for this, but after an OS update you have to delete a line for “REQUEST_INSTALL_PACKAGES” from all the manifest files since that was deprecated.
On iOS, you can use the Cordova package as is, or use the Capacitor Share plugin (doesn’t work on Android to my knowledge because it doesn’t let you save on the device like you can on iOS).
That Capacitor Filesystem Plugin mainly works for the internal app files that nobody can access, normally.
Thanks for your reply.
But… Isnt cordova file opener only for open files?
I need to write file on external storage.
Is it possible with this plugin?
Thanks
Oh right I am a dummy, I totally forgot what I did.
In my case this was my issue. My app created .xlsx and .csv files, and I was using apps that open those files to save to wherever the user wanted. Which is why I used the cordova-file-opener plugin So no, I didn’t fix the issue, or at least how you want it to work. In another project, I used the Share plugin to save locally, but the problem with that process is that on Android it doesn’t have the save option like it does on iOS.
Check the pictures below for the “Save to Files” option. It doesn’t appear on Android. I did find a plugin called Capacitor-File-Opener or something like that, that let me save to Google Drive but that’s about it. I was going to test it on my device to see if I could open files on Google Sheets or MS Excel but right now I am still trying to see if I find a way to do a File Dialog like I can do on Windows.
On iOS:

On Android:

Heyya @chidav770 @bandito Any good progress with this?
I am using Capacitor 4 and trying to save photos from my app to the public storage (Directory.Documents
). Only works up to Android 12. Receives permission denied
error in Android 13.
I found I could successfully create a folder inside the Documents directory… maybe call it the name of you app. I.E Documents/myApp. I could then write my files to that folder. I did this recently, for an app update on android 12.and I’m sure this was tested and working for android 13. I hope it helps you
here’s a snippet for the folder creation
export function createDirectories() {
const directories = [
"/myApp",
"/myApp/images",
"/myApp/documents",
];
for (const dir of directories) {
Filesystem.mkdir({
path: dir,
directory: Directory.Documents,
recursive: true,
});
}
}