Skip to main content
Hand a file to the app the system associates with its type: a PDF viewer for .pdf, an image viewer for .jpg. Your app doesn’t read the content. The function is not available on the web, so call it from a non-web source set such as nonWebMain (see shared source sets).

Usage

openFileWithDefaultApplication is a regular function, not a suspend function, so you can call it directly from a click handler. There is no Compose launcher.

Options

PlatformFile
required
The file to open. It must exist.
FileKitOpenFileSettings
default:"createDefault()"
Platform-specific settings.

Platform notes

Failures are reported differently on each platform. Only the JVM wraps some of them in FileKitDialogException:

Android setup

Only needed for files outside FileKit.filesDir and FileKit.cacheDir. filekit-dialogs already ships a FileProvider (${applicationId}.FileKitFileProvider) that covers those two directories, and content:// files returned by the pickers need no provider at all. For any other location, such as getExternalFilesDir(), FileProvider throws an IllegalArgumentException until you declare your own provider.
1

Declare a provider in your manifest

AndroidManifest.xml
2

List the directories it may expose

Add one entry per location you use, for example app-specific external storage:
res/xml/file_paths.xml
See FileProvider for every path type.
3

Pass the authority to FileKit

The authority parameter exists only on Android, so build these settings in androidMain:
androidMain