The Problem
The official DataStore setup requiresexpect/actual declarations with platform-specific implementations:
- Android needs
Context.filesDir - iOS needs
NSDocumentDirectory - JVM needs
System.getProperty("java.io.tmpdir")or a custom path
androidMain, iosMain, and jvmMain source sets.
The Solution
With FileKit, you can define everything incommonMain:
Complete Example
Here’s a complete setup for a preferences manager:Why databasesDir?
FileKit.databasesDir returns a platform-appropriate location for persistent data:
This ensures your preferences are stored in a safe, persistent location on each platform.