Android
android.os
public class

android.os.ParcelFileDescriptor

java.lang.Object
android.os.ParcelFileDescriptor Parcelable

The FileDescriptor returned by readFileDescriptor(), allowing you to close it when done with it.

Nested Classes
ParcelFileDescriptor.AutoCloseInputStream An InputStream you can create on a ParcelFileDescriptor, which will take care of calling ParcelFileDescritor.close() for you when the stream is closed. 
ParcelFileDescriptor.AutoCloseOutputStream An OutputStream you can create on a ParcelFileDescriptor, which will take care of calling ParcelFileDescritor.close() for you when the stream is closed. 

Summary

Constants

      Value  
Creator<ParcelFileDescriptor CREATOR       
int  MODE_CREATE  For use with open(File, int): create the file if it doesn't already exist.  134217728  0x08000000 
int  MODE_READ_ONLY  For use with open(File, int): open the file with read-only access.  268435456  0x10000000 
int  MODE_READ_WRITE  For use with open(File, int): open the file with read and write access.  805306368  0x30000000 
int  MODE_TRUNCATE  For use with open(File, int): erase contents of file when opening.  67108864  0x04000000 
int  MODE_WORLD_READABLE  For use with open(File, int): if MODE_CREATE has been supplied and this file doesn't already exist, then create the file with permissions such that any application can read it.  0x00000001 
int  MODE_WORLD_WRITEABLE  For use with open(File, int): if MODE_CREATE has been supplied and this file doesn't already exist, then create the file with permissions such that any application can write it.  0x00000002 
int  MODE_WRITE_ONLY  For use with open(File, int): open the file with write-only access.  536870912  0x20000000 
Constants inherited from interface android.os.Parcelable

Public Constructors

            ParcelFileDescriptor(ParcelFileDescriptor descriptor)

Public Methods

          void  close()
Close the ParcelFileDescriptor.
          int  describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
      static    ParcelFileDescriptor  fromSocket(Socket socket)
Create a new ParcelFileDescriptor from the specified Socket.
          FileDescriptor  getFileDescriptor()
Retrieve the actual FileDescriptor associated with this object.
      static    ParcelFileDescriptor  open(File file, int mode)
Create a new ParcelFileDescriptor accessing a given file.
          String  toString()
Returns a string containing a concise, human-readable description of the receiver.
          void  writeToParcel(Parcel out, int flags)
Flatten this object in to a Parcel.

Protected Methods

          void  finalize()
Called by the virtual machine when there are no longer any (non-weak) references to the receiver.
Methods inherited from class java.lang.Object
Methods inherited from interface android.os.Parcelable

Details

Constants

public static final Creator<ParcelFileDescriptor> CREATOR

public static final int MODE_CREATE

For use with open(File, int): create the file if it doesn't already exist.
Constant Value: 134217728 (0x08000000)

public static final int MODE_READ_ONLY

For use with open(File, int): open the file with read-only access.
Constant Value: 268435456 (0x10000000)

public static final int MODE_READ_WRITE

For use with open(File, int): open the file with read and write access.
Constant Value: 805306368 (0x30000000)

public static final int MODE_TRUNCATE

For use with open(File, int): erase contents of file when opening.
Constant Value: 67108864 (0x04000000)

public static final int MODE_WORLD_READABLE

For use with open(File, int): if MODE_CREATE has been supplied and this file doesn't already exist, then create the file with permissions such that any application can read it.
Constant Value: 1 (0x00000001)

public static final int MODE_WORLD_WRITEABLE

For use with open(File, int): if MODE_CREATE has been supplied and this file doesn't already exist, then create the file with permissions such that any application can write it.
Constant Value: 2 (0x00000002)

public static final int MODE_WRITE_ONLY

For use with open(File, int): open the file with write-only access.
Constant Value: 536870912 (0x20000000)

Public Constructors

public ParcelFileDescriptor(ParcelFileDescriptor descriptor)

Public Methods

public void close()

Close the ParcelFileDescriptor. This implementation closes the underlying OS resources allocated to represent this stream.

Throws

IOException If an error occurs attempting to close this ParcelFileDescriptor.

public int describeContents()

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

public static ParcelFileDescriptor fromSocket(Socket socket)

Create a new ParcelFileDescriptor from the specified Socket.

Parameters

socket The Socket whose FileDescriptor is used to create a new ParcelFileDescriptor.

Returns

  • A new ParcelFileDescriptor with the FileDescriptor of the specified Socket.

public FileDescriptor getFileDescriptor()

Retrieve the actual FileDescriptor associated with this object.

Returns

  • Returns the FileDescriptor associated with this object.

public static ParcelFileDescriptor open(File file, int mode)

Create a new ParcelFileDescriptor accessing a given file.

Parameters

file The file to be opened.
mode The desired access mode, must be one of MODE_READ_ONLY, MODE_WRITE_ONLY, or MODE_READ_WRITE; may also be any combination of MODE_CREATE, MODE_TRUNCATE, MODE_WORLD_READABLE, and MODE_WORLD_WRITEABLE.

Returns

  • Returns a new ParcelFileDescriptor pointing to the given file.

Throws

FileNotFoundException Throws FileNotFoundException if the given file does not exist or can not be opened with the requested mode.

public String toString()

Returns a string containing a concise, human-readable description of the receiver.

Returns

  • String a printable representation for the receiver.

public void writeToParcel(Parcel out, int flags)

Flatten this object in to a Parcel.

Protected Methods

protected void finalize()

Called by the virtual machine when there are no longer any (non-weak) references to the receiver. Subclasses can use this facility to guarantee that any associated resources are cleaned up before the receiver is garbage collected. Uncaught exceptions which are thrown during the running of the method cause it to terminate immediately, but are otherwise ignored.

Note: The virtual machine assumes that the implementation in class Object is empty.

Throws

Throwable
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56