Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# FileChooserParams

*** ** * ** ***

```
abstract class FileChooserParams
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.webkit.WebChromeClient.FileChooserParams](https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#) |

Parameters used in the `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient#onShowFileChooser(android.webkit.WebView,%20android.webkit.ValueCallback,%20android.webkit.WebChromeClient.FileChooserParams)` method.

## Summary

| Constants ||
|---|---|
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#MODE_OPEN:kotlin.Int` Open single file. |
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#MODE_OPEN_FOLDER:kotlin.Int` Like Open but allows a folder to be selected. |
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#MODE_OPEN_MULTIPLE:kotlin.Int` Like Open but allows multiple files to be selected. |
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#MODE_SAVE:kotlin.Int` Allows picking a nonexistent file and saving it. |
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#PERMISSION_MODE_READ:kotlin.Int` File or directory should be opened for reading only. |
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#PERMISSION_MODE_READ_WRITE:kotlin.Int` File or directory should be opened for read and write. |

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#FileChooserParams()()` <br /> |

| Public methods ||
|---|---|
| abstract [Intent](https://developer.android.com/reference/kotlin/android/content/Intent.html#)! | `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#createIntent()()` Creates an intent that would start a file picker for file selection. |
| abstract [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>! | `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#getAcceptTypes()()` Returns an array of acceptable MIME types. |
| abstract [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)? | `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#getFilenameHint()()` The file name of a default selection if specified, or `null`. |
| abstract [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#getMode()()` Returns file chooser mode. |
| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#getPermissionMode()()` Returns permission mode `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#PERMISSION_MODE_READ:kotlin.Int` or `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#PERMISSION_MODE_READ_WRITE:kotlin.Int` which indicates the intended mode for opening a file or directory. |
| abstract [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)? | `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#getTitle()()` Returns the title to use for this file selector. |
| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#isCaptureEnabled()()` Returns preference for a live media captured value (e.g. Camera, Microphone). |
| open static [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\<[Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)!\>? | `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#parseResult(kotlin.Int,%20android.content.Intent)(resultCode: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, data: https://developer.android.com/reference/kotlin/android/content/Intent.html#!)` Parse the result returned by the file picker activity. |

## Constants

### MODE_OPEN

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
static val MODE_OPEN: Int
```

Open single file. Requires that the file exists before allowing the user to pick it.

    Value: 0

### MODE_OPEN_FOLDER

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
static val MODE_OPEN_FOLDER: Int
```

Like Open but allows a folder to be selected.

    Value: 2

### MODE_OPEN_MULTIPLE

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
static val MODE_OPEN_MULTIPLE: Int
```

Like Open but allows multiple files to be selected.

    Value: 1

### MODE_SAVE

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
static val MODE_SAVE: Int
```

Allows picking a nonexistent file and saving it.

    Value: 3

### PERMISSION_MODE_READ

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
static val PERMISSION_MODE_READ: Int
```

File or directory should be opened for reading only.

    Value: 0

### PERMISSION_MODE_READ_WRITE

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
static val PERMISSION_MODE_READ_WRITE: Int
```

File or directory should be opened for read and write.

    Value: 1

## Public constructors

### FileChooserParams

```
FileChooserParams()
```

## Public methods

### createIntent

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
abstract fun createIntent(): Intent!
```

Creates an intent that would start a file picker for file selection. The Intent supports choosing files from simple file sources available on the device. Some advanced sources (for example, live media capture) may not be supported and applications wishing to support these sources or more advanced file operations should build their own Intent.

How to use:

1. Build an intent using `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#createIntent()`
2. Fire the intent using android.app.Activity#startActivityForResult.
3. Check for ActivityNotFoundException and take a user friendly action if thrown.
4. Listen the result using android.app.Activity#onActivityResult
5. Parse the result using `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#parseResult(kotlin.Int,%20android.content.Intent)` only if media capture was not requested.
6. Send the result using filePathCallback of `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient#onShowFileChooser(android.webkit.WebView,%20android.webkit.ValueCallback,%20android.webkit.WebChromeClient.FileChooserParams)`

**Note:** The created intent may be handled by third-party applications on device. The received result must be treated as untrusted as it can contain Uris pointing to your own app's sensitive data files. Your app should check the resultant Uris in `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#parseResult(kotlin.Int,%20android.content.Intent)` before calling the `filePathCallback`.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/content/Intent.html#!` | an Intent that supports basic file chooser sources. |

### getAcceptTypes

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
abstract fun getAcceptTypes(): Array<String!>!
```

Returns an array of acceptable MIME types. The returned MIME type could be partial such as audio/\*. The array will be empty if no acceptable types are specified.

### getFilenameHint

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
abstract fun getFilenameHint(): String?
```

The file name of a default selection if specified, or `null`.

### getMode

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
abstract fun getMode(): Int
```

Returns file chooser mode.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | Value is one of the following: - `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#MODE_OPEN:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#MODE_OPEN_MULTIPLE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#MODE_OPEN_FOLDER:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#MODE_SAVE:kotlin.Int` |

### getPermissionMode

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun getPermissionMode(): Int
```

Returns permission mode `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#PERMISSION_MODE_READ:kotlin.Int` or `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#PERMISSION_MODE_READ_WRITE:kotlin.Int` which indicates the intended mode for opening a file or directory. This can be used to determine whether an Intent such as `https://developer.android.com/reference/kotlin/android/content/Intent.html#ACTION_OPEN_DOCUMENT:kotlin.String` should be used rather than `https://developer.android.com/reference/kotlin/android/content/Intent.html#ACTION_GET_CONTENT:kotlin.String` to choose files.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | Value is one of the following: - `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#PERMISSION_MODE_READ:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#PERMISSION_MODE_READ_WRITE:kotlin.Int` |

### getTitle

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
abstract fun getTitle(): CharSequence?
```

Returns the title to use for this file selector. If `null` a default title should be used.

### isCaptureEnabled

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
abstract fun isCaptureEnabled(): Boolean
```

Returns preference for a live media captured value (e.g. Camera, Microphone). True indicates capture is enabled, `false` disabled. Use `getAcceptTypes` to determine suitable capture devices.

### parseResult

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open static fun parseResult(
    resultCode: Int, 
    data: Intent!
): Array<Uri!>?
```

Parse the result returned by the file picker activity. This method should be used with `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#createIntent()`. Refer to `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#createIntent()` for how to use it.

**Note:** The intent returned by the file picker activity should be treated as untrusted. A third-party app handling the implicit intent created by `https://developer.android.com/reference/kotlin/android/webkit/WebChromeClient.FileChooserParams#createIntent()` might return Uris that the third-party app itself does not have access to, such as your own app's sensitive data files. WebView does not enforce any restrictions on the returned Uris. It is the app's responsibility to ensure that the untrusted source (such as a third-party app) has access the Uris it has returned and that the Uris are not pointing to any sensitive data files.

| Parameters ||
|---|---|
| `resultCode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the integer result code returned by the file picker activity. |
| `data` | [Intent](https://developer.android.com/reference/kotlin/android/content/Intent.html#)!: the intent returned by the file picker activity. |

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/android/net/Uri.html#!>?` | the Uris of selected file(s) or `null` if the resultCode indicates activity canceled or any other error. |