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

# DataShareWriteAdapter

*** ** * ** ***

` public interface DataShareWriteAdapter `   
` `

|---|
| android.view.contentcapture.DataShareWriteAdapter |

<br />

*** ** * ** ***

Adapter class used by apps to share data with the Content Capture service.

## Summary

| ### Public methods ||
|---|---|
| ` default void` | ` https://developer.android.com/reference/android/view/contentcapture/DataShareWriteAdapter#onError(int)(int errorCode) ` Method invoked when an error occurred, for example sessions has not been started or terminated unsuccessfully. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/contentcapture/DataShareWriteAdapter#onRejected()() ` Data share sessions has been rejected by the Content Capture service. |
| ` abstract void` | ` https://developer.android.com/reference/android/view/contentcapture/DataShareWriteAdapter#onWrite(android.os.ParcelFileDescriptor)(https://developer.android.com/reference/android/os/ParcelFileDescriptor destination) ` Method invoked when the data share session has been started and the app needs to start writing into the file used for sharing. |

## Public methods

### onError

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

```
public void onError (int errorCode)
```

Method invoked when an error occurred, for example sessions has not been started or terminated unsuccessfully.

<br />

| Parameters ||
|---|---|
| `errorCode` | `int`: the error code corresponding to an ERROR_\* value. Value is one of the following: - `https://developer.android.com/reference/android/view/contentcapture/ContentCaptureManager#DATA_SHARE_ERROR_UNKNOWN` - `https://developer.android.com/reference/android/view/contentcapture/ContentCaptureManager#DATA_SHARE_ERROR_CONCURRENT_REQUEST` - `https://developer.android.com/reference/android/view/contentcapture/ContentCaptureManager#DATA_SHARE_ERROR_TIMEOUT_INTERRUPTED` |

### onRejected

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

```
public abstract void onRejected ()
```

Data share sessions has been rejected by the Content Capture service.

<br />

### onWrite

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

```
public abstract void onWrite (ParcelFileDescriptor destination)
```

Method invoked when the data share session has been started and the app needs to start writing into the file used for sharing.

App needs to handle explicitly cases when the file descriptor is closed and handle gracefully if IOExceptions happen.

<br />

| Parameters ||
|---|---|
| `destination` | `ParcelFileDescriptor`: file descriptor used to write data into. This value cannot be `null`. <br /> |