开发者

What is ParcelFileDescriptor in android

I read about ParcelFileDe开发者_高级运维scriptor from below link.

http://developer.android.com/reference/android/os/ParcelFileDescriptor.html

but I haven't got any idea from it. What is it? and What can it do?

Can anyone explain me?


What it is?

A file descriptor is an object that a process uses to read or write to an open file and open network sockets.

FileDescriptor objects, representing raw Linux file descriptor identifiers, can be written and ParcelFileDescriptor objects returned to operate on the original file descriptor. The returned file descriptor is a dup of the original file descriptor: the object and fd is different, but operating on the same underlying file stream, with the same position.

and What can it do?

Create pipes, create fds from sockets, open/close files.


It implements the Parcable API, which allow put it into Bundles and Intents. It may be even possible to send a FileDescriptor between process. (I have not tested this).

Also the VPNService gives you a ParcelFileDescriptor.


Whenever a file is opened, the operating system creates an entry to represent this file and stores its information. Each entry is represented by an integer value and this entry is termed as file descriptor. Basically, Java class FileDescriptor provides a handle to the underlying machine-specific structure representing an open file, an open socket, or another source or sink of bytes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜