My File System tasks no longer function on New Build

Using Cordova-Plugin-File; Worked well in the past using strings like:
“Android/data/com.nsbasic.AppName/files/”
now The following Fails (fail1) with error code 2 (File Not Found?)

Dim gfolder = "Android/data/com.nsbasic.AppName/files/Photos"   'Directory to store the photo
Dim gPDFfolder = "Android/data/com.nsbasic.AppName/files/PDFs"   'Directory to store the photo

document.addEventListener("deviceready", onDeviceReady, False)

Function onDeviceReady()
              window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFileSys, fail0)        
 End Function

Function gotFileSys(fs)
              gfileSystem = fs
              gfileSystem.root.getDirectory(gfolder, {create: True, exclusive: False}, SubSuccess, fail1)
              gfileSystem.root.getDirectory(gPDFfolder, {create: True, exclusive: False}, 
              SubSuccessPDF, fail1)
              navigator.splashscreen.hide()
End Function

Any Ideas?

There have been some changes in Android 12 regarding permissions on reading and writing to the device storage.

Are you using the latest plugins?

Are there any error messages on the Remote Debugger?

I will get the debugger info. The error code is : 2 (File not Found). are there permission staements needed in the Config.html?

Maybe a permissions issue?
The below:
var gfolder = cordova.file.dataDirectory + “/Photos”;

Yields:
Uncaught TypeError: Cannot read properties of undefined (reading ‘dataDirectory’)
at code.js:18846:28

Try adding this to your config:

<preference name="hostname" value="localhost" /> 
<preference name="AndroidInsecureFileModeEnabled" value="true" />

Simply supplying strings to the plugin commands no longer function. I had supply the getDirectory() command this variation resolveLocalFileSystemURL(dataDirectory) + “Photos” before I was able to create the directory. I always used ABSOLUTE PATHS BEFORE.

Jimmy

I use this plugin without any issues.

<plugin name="cordova-plugin-file" source="npm" />

With this set in the config:

<preference name="hostname" value="localhost" />
<preference name="AndroidInsecureFileModeEnabled" value="true" />

<plugin name="cordova-plugin-androidx-adapter" />
<engine name="android" spec="12.0.0" />

<platform name="android" >
  <preference name="AndroidPersistentFileLocation" value="Internal" />
  <preference name="AndroidExtraFilesystems" value="files,files-external,documents,sdcard,cache,cache-external" />
  <preference name="AndroidXEnabled" value="true" />
  <preference name="android-targetSdkVersion" value="33" />
</platform>

Try replacing:

Function gotFileSys(fs)
              gfileSystem = fs
              gfileSystem.root.getDirectory(gfolder, {create: True, exclusive: False}, SubSuccess, fail1)
              gfileSystem.root.getDirectory(gPDFfolder, {create: True, exclusive: False}, 
              SubSuccessPDF, fail1)
              navigator.splashscreen.hide()
End Function

with this:

Function gotFileSys(fs)
              console.log(fs.root);
              var directoryEntry = fs.root;
              directoryEntry.getDirectory("Photos", {create: True, exclusive: False}, SubSuccess, fail1)
              directoryEntry.getDirectory("PDFs", {create: True, exclusive: False}, 
              SubSuccessPDF, fail1)
              navigator.splashscreen.hide()
End Function

It also replaces the variable “gfolder” with “Photos” and gPDFfolder with “PDFs”