Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/os/ProxyFileDescriptorCallback#pubctors) \| [Methods](https://developer.android.com/reference/android/os/ProxyFileDescriptorCallback#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/os/ProxyFileDescriptorCallback#inhmethods)

# ProxyFileDescriptorCallback

*** ** * ** ***

` public abstract class ProxyFileDescriptorCallback `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.os.ProxyFileDescriptorCallback |

<br />

*** ** * ** ***

Callback that handles file system requests from ProxyFileDescriptor. All callback methods except for onRelease should throw `https://developer.android.com/reference/android/system/ErrnoException` with proper errno on errors. See [errno(3)](http://man7.org/linux/man-pages/man3/errno.3.html) and `https://developer.android.com/reference/android/system/OsConstants`. Typical errnos are

- `https://developer.android.com/reference/android/system/OsConstants#EIO` for general I/O issues
- `https://developer.android.com/reference/android/system/OsConstants#ENOENT` when the file is not found
- `https://developer.android.com/reference/android/system/OsConstants#EBADF` if the file doesn't allow read/write operations based on how it was opened. (For example, trying to write a file that was opened read-only.)
- `https://developer.android.com/reference/android/system/OsConstants#ENOSPC` if you cannot handle a write operation to space/quota limitations.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/storage/StorageManager#openProxyFileDescriptor(int,%20android.os.ProxyFileDescriptorCallback,%20android.os.Handler)`

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/os/ProxyFileDescriptorCallback#ProxyFileDescriptorCallback()() ` |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/os/ProxyFileDescriptorCallback#onFsync()() ` Ensures all the written data are stored in permanent storage device. |
| ` long` | ` https://developer.android.com/reference/android/os/ProxyFileDescriptorCallback#onGetSize()() ` Returns size of bytes provided by the file descriptor. |
| ` int` | ` https://developer.android.com/reference/android/os/ProxyFileDescriptorCallback#onRead(long,%20int,%20byte[])(long offset, int size, byte[] data) ` Provides bytes read from file descriptor. |
| ` abstract void` | ` https://developer.android.com/reference/android/os/ProxyFileDescriptorCallback#onRelease()() ` Invoked after the file is closed. |
| ` int` | ` https://developer.android.com/reference/android/os/ProxyFileDescriptorCallback#onWrite(long,%20int,%20byte[])(long offset, int size, byte[] data) ` Handles bytes written to file descriptor. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### ProxyFileDescriptorCallback

```
public ProxyFileDescriptorCallback ()
```

<br />

<br />

## Public methods

### onFsync

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

```
public void onFsync ()
```

Ensures all the written data are stored in permanent storage device. For example, if it has data stored in on memory cache, it needs to flush data to storage device.

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/system/ErrnoException` | ErrnoException containing E constants in OsConstants. |

### onGetSize

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

```
public long onGetSize ()
```

Returns size of bytes provided by the file descriptor.

<br />

| Returns ||
|---|---|
| `long` | Size of bytes. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/system/ErrnoException` | ErrnoException containing E constants in OsConstants. |

### onRead

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

```
public int onRead (long offset, 
                int size, 
                byte[] data)
```

Provides bytes read from file descriptor. It needs to return exact requested size of bytes unless it reaches file end.

<br />

| Parameters ||
|---|---|
| `offset` | `long`: Offset in bytes from the file head specifying where to read bytes. If a seek operation is conducted on the file descriptor, then a read operation is requested, the offset refrects the proper position of requested bytes. <br /> |
| `size` | `int`: Size for read bytes. <br /> |
| `data` | `byte`: Byte array to store read bytes. <br /> |

| Returns ||
|---|---|
| `int` | Size of bytes returned by the function. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/system/ErrnoException` | ErrnoException containing E constants in OsConstants. |

### onRelease

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

```
public abstract void onRelease ()
```

Invoked after the file is closed.

<br />

### onWrite

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

```
public int onWrite (long offset, 
                int size, 
                byte[] data)
```

Handles bytes written to file descriptor.

<br />

| Parameters ||
|---|---|
| `offset` | `long`: Offset in bytes from the file head specifying where to write bytes. If a seek operation is conducted on the file descriptor, then a write operation is requested, the offset refrects the proper position of requested bytes. <br /> |
| `size` | `int`: Size for write bytes. <br /> |
| `data` | `byte`: Byte array to be written to somewhere. <br /> |

| Returns ||
|---|---|
| `int` | Size of bytes processed by the function. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/system/ErrnoException` | ErrnoException containing E constants in OsConstants. |