Standard Directories
Supported on Android, iOS, macOS, JVM, and Kotlin/Native Linux targets
Platform-specific Directory Behavior
Each platform maps these standard directories to different locations according to platform conventions: Android- filesDir: Maps to
context.filesDir, which is the app’s private internal storage - cacheDir: Maps to
context.cacheDir, which is the app’s private cache directory - databasesDir: Maps to a
databasessubdirectory in the app’s internal storage
- filesDir: Maps to the app’s Documents directory, which is backed up with iCloud
- cacheDir: Maps to the app’s Caches directory, which isn’t backed up and may be cleared by the system
- databasesDir: Maps to a
databasessubdirectory in the app’s Documents directory
- filesDir: Maps to
~/Library/Application Support/<app-id>/, requiring FileKit initialization with an app ID - cacheDir: Maps to
~/Library/Caches/<app-id>/ - databasesDir: Maps to a
databasessubdirectory in the application support directory
- filesDir: Maps to platform-specific app data locations:
- Linux:
~/.local/share/<app-id>/ - macOS:
~/Library/Application Support/<app-id>/ - Windows:
%APPDATA%/<app-id>/
- Linux:
- cacheDir: Maps to platform-specific cache locations:
- Linux:
~/.cache/<app-id>/ - macOS:
~/Library/Caches/<app-id>/ - Windows:
%LOCALAPPDATA%/<app-id>/Cache/
- Linux:
- databasesDir: Maps to a
databasessubdirectory within filesDir
linuxX64, linuxArm64)
- filesDir: Maps to
$XDG_DATA_HOME/<app-id>/, or~/.local/share/<app-id>/whenXDG_DATA_HOMEis unset - cacheDir: Maps to
$XDG_CACHE_HOME/<app-id>/, or~/.cache/<app-id>/whenXDG_CACHE_HOMEis unset - databasesDir: Maps to a
databasessubdirectory within filesDir
On JVM, macOS, and Kotlin/Native Linux platforms, you must initialize FileKit with an application ID before accessing these directories. See the Setup guide for details.
Additional Directories
On desktop platforms (JVM, macOS, and Kotlin/Native Linux), FileKit provides access to common user directories:FileKit.userDirectoryOrNull(...) when you prefer nullable handling instead of exceptions.
Directory Usage Example
Scoped Resource Access (iOS/macOS)
On iOS and macOS, some files may require security-scoped access to be read or written. FileKit provides utilities to manage this:withScopedAccess method:
Downloading files from web
Supported on JS and WASM targets