# ActivityResultContracts.CreateDocument

Artifact: [androidx.activity:activity](https://developer.android.com/jetpack/androidx/releases/activity) [View Source](https://cs.android.com/search?q=file:androidx/activity/result/contract/ActivityResultContracts.kt+class:androidx.activity.result.contract.ActivityResultContracts.CreateDocument) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/activity#1.2.0)

*** ** * ** ***


```
public class ActivityResultContracts.CreateDocument extends ActivityResultContract<@NonNull String, Uri>
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.activity.result.contract.ActivityResultContract](https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContract)\<@[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull) [String](https://developer.android.com/reference/java/lang/String.html), [Uri](https://developer.android.com/reference/android/net/Uri.html)\> ||
|   | ↳ | [androidx.activity.result.contract.ActivityResultContracts.CreateDocument](https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContracts.CreateDocument) |

*** ** * ** ***

An `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContract` to prompt the user to select a path for creating a new document of the given `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContracts.CreateDocument#mimeType()`, returning the `content:` `https://developer.android.com/reference/android/net/Uri.html` of the item that was created.

The input is the suggested name for the new file.

This can be extended to override `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContracts.CreateDocument#createIntent(android.content.Context,kotlin.String)` if you wish to pass additional extras to the Intent created by `super.createIntent()`.

## Summary

| ### Public constructors |
|---|
| `[CreateDocument](https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContracts.CreateDocument#CreateDocument())()` **This method is deprecated.** Using a wildcard mime type with CreateDocument is not recommended as it breaks the automatic handling of file extensions. |
| `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContracts.CreateDocument#CreateDocument(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html mimeType)` |

| ### Public methods |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html` | `@https://developer.android.com/reference/androidx/annotation/CallSuper https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContracts.CreateDocument#createIntent(android.content.Context,kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html input)` Create an intent that can be used for `https://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int)`. |
| `final https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContract.SynchronousResult<https://developer.android.com/reference/android/net/Uri.html>` | `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContracts.CreateDocument#getSynchronousResult(android.content.Context,kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html input)` An optional method you can implement that can be used to potentially provide a result in lieu of starting an activity. |
| `final https://developer.android.com/reference/android/net/Uri.html` | `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContracts.CreateDocument#parseResult(kotlin.Int,android.content.Intent)(int resultCode, https://developer.android.com/reference/android/content/Intent.html intent)` Convert result obtained from `https://developer.android.com/reference/android/app/Activity.html#onActivityResult(int, int, android.content.Intent)` to `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContract`. |

## Public constructors

### CreateDocument

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/activity#1.2.0) Deprecated in [1.5.0](https://developer.android.com/jetpack/androidx/releases/activity#1.5.0)

```
public [CreateDocument](https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContracts.CreateDocument#CreateDocument())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Using a wildcard mime type with CreateDocument is not recommended as it breaks the automatic handling of file extensions. Instead, specify the mime type by using the constructor that takes an concrete mime type (e.g.., CreateDocument("image/png")), use this instead:
>
> ```
> CreateDocument("todo/todo")
> ```

### CreateDocument

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/activity#1.5.0)

```
public CreateDocument(@NonNull String mimeType)
```

## Public methods

### createIntent

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/activity#1.2.0)

```
@CallSuper
public @NonNull Intent createIntent(@NonNull Context context, @NonNull String input)
```

Create an intent that can be used for `https://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int)`.

### getSynchronousResult

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/activity#1.2.0)

```
public final ActivityResultContract.SynchronousResult<Uri> getSynchronousResult(@NonNull Context context, @NonNull String input)
```

An optional method you can implement that can be used to potentially provide a result in lieu of starting an activity.

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContract.SynchronousResult<https://developer.android.com/reference/android/net/Uri.html>` | the result wrapped in a `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContract.SynchronousResult` or `null` if the call should proceed to start an activity. |

### parseResult

```
public final Uri parseResult(int resultCode, Intent intent)
```

Convert result obtained from `https://developer.android.com/reference/android/app/Activity.html#onActivityResult(int, int, android.content.Intent)` to `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContract`.