Skip to main content

MobileFilePicker

Kindclass
Packagemobile.files
Full namemobile.files.MobileFilePicker
Sourcesource/mobile/files/MobileFilePicker.hx

Cross-platform file picker facade.

On Android it drives the native Storage Access Framework document picker (ACTION_OPEN_DOCUMENT / ACTION_CREATE_DOCUMENT / ACTION_OPEN_DOCUMENT_TREE); on desktop it uses Lime's native file dialogs. Results come back through callbacks with null meaning the user canceled (or the operation is unsupported on this target).

This is what editors (charting, character, ...) should use instead of calling lime.ui.FileDialog directly, so imports/exports work on mobile.

Public methods​

openFile​

static function openFile(onResult:PickedFile->Void, ?extensions:Array<String>, ?title:String):Bool

Opens a file picker and reads the picked file into memory.

@param onResult called with the picked file, or null when canceled @param extensions optional extension filter, e.g. ["json"] @param title optional picker title @return false when picking is not supported on this target

ParameterTypeDefault
onResultPickedFile->Void, ?extensions:Array<String>, ?title:String—

View source

saveFile​

static function saveFile(data:Bytes, suggestedName:String, ?mime:String, ?title:String, onDone:String->Void = null):Bool

Opens a "save as" picker and writes the data to the picked location.

@param onDone called with the resulting path (desktop) or content URI (Android), or null when canceled/unsupported @return false when saving is not supported on this target

ParameterTypeDefault
dataBytes—
suggestedNameString—
mime (optional)String—
title (optional)String—
onDoneString->Void = null—

View source

saveText​

static function saveText(text:String, suggestedName:String, ?mime:String, ?title:String, onDone:String->Void = null):Bool

Convenience wrapper for saving text content.

ParameterTypeDefault
textString—
suggestedNameString—
mime (optional)String—
title (optional)String—
onDoneString->Void = null—

View source

openFolder​

static function openFolder(onResult:String->Void, ?title:String):Bool

Opens a directory picker. @param onResult called with the picked directory path (desktop) or tree URI (Android), or null when canceled

ParameterTypeDefault
onResultString->Void, ?title:String—

View source

Internals​

Private / internal members
FieldTypeStatic
activeDialogDynamicyes
Method
static function guessMime(fileName:String):String