English | Site Directory

Android - An Open Handset Alliance Project

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  CREATOR       
int  MODE_CREATE  For use with open(File, int): create the file if it doesn't already exist.  0x00000002 
int  MODE_READ  For use with open(File, int): open the file with read access.  0x00000000 
int  MODE_READ_WRITE  For use with open(File, int): open the file with read and write access.  0x00000001 
int  MODE_TRUNCATE  For use with open(File, int): erase contents of file when opening.  0x00000004 

Public Methods

        void  close()
Close the ParcelFileDescriptor.
        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()
Answers a string containing a concise, human-readable description of the receiver.
        void  writeToParcel(Parcel out)
Methods inherited from class java.lang.Object
Methods inherited from interface android.os.Parcelable

Details

Constants

public static final Creator CREATOR

public static final int MODE_CREATE

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

public static final int MODE_READ

For use with open(File, int): open the file with read access.
Constant Value: 0 (0x00000000)

public static final int MODE_READ_WRITE

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

public static final int MODE_TRUNCATE

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

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 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, may be MODE_READ, MODE_READ_WRITE, MODE_CREATE, MODE_TRUNCATE.

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()

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

public void writeToParcel(Parcel out)

Build m5-rc15g - 14 May 2008 12:50