This works on a couple of phones running Android 9 (I don’t have a device with Android 10). It does NOT work on a Pixel running Android 11. The promise returns null.
Things I have tried:
Used checkDir() to verify that the directory exists Used FileChooser and filePath.resolveNativePath Used androidPermissions READ_EXTERNAL_STORAGE is set to true
Thanks for the comment. I believe my permissions are ok. Like I mentioned in my original post I am using the android-permissions plugin to verify that READ_EXTERNAL_STORAGE is true. The last post in the link you provided states the following which seemed to be my situation. I have permission but the promise is returning null when trying to read.
@fragatak thanks! I’ve the permissions for the storage, but the file content is just “null”. Do you have any idea?
As of API 29, there is a new file system policy. As long as you are targeting API 29 which the latest version of cordova-android does you can add the following flag to the config.xml to get it working:
add it in your config.xml file and problem will be solved.It worked for me.
in android 10 or android api 29
before adding this android:requestLegacyExternalStorage="true"
while debugging you will get pop up access like this allow myapp to access photos and media on your device
after adding this android:requestLegacyExternalStorage="true"
you will see allow contacts to access photos media and files on your device.