Cordova to Capacitor File Conversion
Cordova and Capacitor use different conventions and aliases to refer to standard directories on iOS and Android.
I checked the source code and here is how the different aliases map up:
Android Conversion
Device Path | cordova.file.* | AndroidExtraFileSystems | Capacitor Directory | Available with requestLegacyExternalStorage | Restrictions on Android 11+ | Native Command | r/w? | persistent? | OS clears | private |
file:///android_asset/ | applicationDirectory | assets | r | N/A | N/A | Yes | ||||
/data/data/<app-id>/ | applicationStorageDirectory | - | r/w | N/A | N/A | Yes | ||||
/data/data/<app-id>/cache | cacheDirectory | cache | CACHE | context.getCacheDir() | r/w | Yes | Yes* | Yes | ||
/data/data/<app-id>/files | dataDirectory | files | DATA, LIBRARY | context.getFilesDir() | r/w | Yes | No | Yes | ||
/data/data/<app-id>/files/Documents | documents | new File(context.getFilesDir(), “Documents”) | r/w | Yes | No | Yes | ||||
<sdcard>/ | externalRootDirectory | sdcard | EXTERNAL_STORAGE | Yes | Generally no access. Only acess files the app created | Environment.getExternalStorageDirectory() | r/w | Yes | No | No |
<sdcard>/Android/data/<app-id>/ | externalApplicationStorageDirectory | - | context.getExternalFilesDir(null).getParentFile() | r/w | Yes | No | No | |||
<sdcard>/Android/data/<app-id>/cache | externalCacheDirectory | cache-external | context.getExternalCacheDir() | r/w | Yes | No** | No | |||
<sdcard>/Android/data/<app-id>/files/ | externalDataDirectory | files-external | EXTERNAL | context.getExternalFilesDir(null) | r/w | Yes | No | No | ||
<sdcard>/Documents | DOCUMENTS | Yes | Generally no access. Only access files the app created | Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) |
iOS Conversion
Device Path | cordova.file.* | iosExtraFileSystems | Capacitor | FileManager.SearchPathDirectory | r/w? | persistent? | OS clears | sync | private |
/var/mobile/Applications/<uuid>/ | applicationStorageDirectory | - | r | N/A | N/A | N/A | Yes | ||
/var/mobile/Applications/<uuid>/appname.app/ | applicationDirectory | bundle | r | N/A | N/A | N/A | Yes | ||
/var/mobile/Applications/<uuid>/appname.app/www/ | - | - | r | N/A | N/A | N/A | Yes | ||
/var/mobile/Applications/<uuid>/Documents/ | documentsDirectory | documents | DOCUMENTS, DATA, EXTERNAL, EXTERNAL_STORAGE | .documentDirectory | r/w | Yes | No | Yes | Yes |
/var/mobile/Applications/<uuid>/Documents/NoCloud/ | - | documents-nosync | r/w | Yes | No | No | Yes | ||
/var/mobile/Applications/<uuid>/Library/ | - | library | LIBRARY | .libraryDirectory | r/w | Yes | No | Yes? | Yes |
/var/mobile/Applications/<uuid>/Library/NoCloud/ | dataDirectory | library-nosync | r/w | Yes | No | No | Yes | ||
/var/mobile/Applications/<uuid>/Library/Cloud/ | syncedDataDirectory | - | r/w | Yes | No | Yes | Yes | ||
/var/mobile/Applications/<uuid>/Library/Caches/ | cacheDirectory | cache | CACHE | .cachesDirectory | r/w | Yes* | Yes*** | No | Yes |
/var/mobile/Applications/<uuid>/tmp/ | tempDirectory | - | r/w | No** | Yes*** | No | Yes |
Sources: