StorageLocation

sealed interface StorageLocation

Cross-platform location to save a PDF document.

Each variant maps to a sensible directory on every platform — see the KDoc on each member for the exact path on Android / iOS. Use the variant that matches the user's expectation rather than the platform's filesystem layout: Downloads always lands in a place users can find from a file manager, even when the platform's "Downloads" doesn't exist in the traditional sense.

On Android, writing to public locations (Downloads, Documents) uses MediaStore on API 29+ (no permission required) and falls back to raw filesystem on older releases (which requires the app to declare WRITE_EXTERNAL_STORAGE and obtain runtime permission).

On iOS, only the app's sandbox is reachable. Downloads therefore maps to the Documents directory; if the app advertises UIFileSharingEnabled

  • LSSupportsOpeningDocumentsInPlace in its Info.plist the user can pick the file up from the Files app.

Inheritors

Types

Link copied to clipboard

App-specific external storage. On Android this is visible from the File Manager under Android/data/<pkg>/files/ and survives app uninstallation only on Android 11 and below. iOS does not have this concept; files land in the standard Documents directory there.

Link copied to clipboard

App-private persistent storage. Files persist for the lifetime of the app installation but are not visible to the user. Best for documents the app needs to keep but the user shouldn't manage.

Link copied to clipboard
data object Cache : StorageLocation

App-private cache directory. Files here may be removed by the OS when the device runs low on space. Best for previews, throwaway temporary documents, or anything the user does not need to persist.

Link copied to clipboard
data class Custom(val path: String) : StorageLocation

Caller-supplied absolute path. Two shapes are accepted:

Link copied to clipboard

Public Documents folder. Same Android / iOS mapping as Downloads, targeting MediaStore.Files with the Documents/ relative path on Android.

Link copied to clipboard

Public Downloads folder.

Link copied to clipboard
data object Temp : StorageLocation

Temporary directory. On iOS this is NSTemporaryDirectory() and is cleared by the system across launches; on Android it shares Cache semantics.