Skip to content

Most visited

Recently visited

navigation

ProxyFileDescriptorCallback

public abstract class ProxyFileDescriptorCallback
extends Object

java.lang.Object
   ↳ android.os.ProxyFileDescriptorCallback


Callback that handles file system requests from ProxyFileDescriptor. All callback methods except for onRelease should throw ErrnoException with proper errno on errors. See errno(3) and OsConstants. Typical errnos are

  • EIO for general I/O issues
  • ENOENT when the file is not found
  • 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.)
  • ENOSPC if you cannot handle a write operation to space/quota limitations.

See also:

Summary

Public constructors

ProxyFileDescriptorCallback()

Public methods

void onFsync()

Ensures all the written data are stored in permanent storage device.

long onGetSize()

Returns size of bytes provided by the file descriptor.

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

Provides bytes read from file descriptor.

abstract void onRelease()

Invoked after the file is closed.

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

Handles bytes written to file descriptor.

Inherited methods

From class java.lang.Object

Public constructors

ProxyFileDescriptorCallback

added in API level 26
ProxyFileDescriptorCallback ()

Public methods

onFsync

added in API level 26
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.

Throws
ErrnoException ErrnoException containing E constants in OsConstants.

onGetSize

added in API level 26
long onGetSize ()

Returns size of bytes provided by the file descriptor.

Returns
long Size of bytes.

Throws
ErrnoException ErrnoException containing E constants in OsConstants.

onRead

added in API level 26
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.

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.

size int: Size for read bytes.

data byte: Byte array to store read bytes.

Returns
int Size of bytes returned by the function.

Throws
ErrnoException ErrnoException containing E constants in OsConstants.

onRelease

added in API level 26
void onRelease ()

Invoked after the file is closed.

onWrite

added in API level 26
int onWrite (long offset, 
                int size, 
                byte[] data)

Handles bytes written to file descriptor.

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.

size int: Size for write bytes.

data byte: Byte array to be written to somewhere.

Returns
int Size of bytes processed by the function.

Throws
ErrnoException ErrnoException containing E constants in OsConstants.
This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)