Reputation: 633
I read about ParcelFileDescriptor
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?
Upvotes: 55
Views: 33416
Reputation: 1035
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.
Upvotes: 2
Reputation: 6322
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.
Upvotes: 9
Reputation: 33792
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.
Upvotes: 23