Contents | Android Developers

Quicknav Quicknav
Links

- Google Play Developer Console
- Android Developers Blog
- About Android

Android Sites

- Android.com
- Android Developers
- Android Open Source Project

Language
close

- - About
  - Wear
  - TV
  - Auto
- - Get Started
  - Devices
  - Style
  - Patterns
  - Building Blocks
  - Downloads
  - Videos
- - Training
  - API Guides
  - Reference
  - Tools
  - Google Services
  - Samples
- - Google Play
  - Essentials
  - Get Users
  - Engage & Retain
  - Monetize
  - Tools & Reference
  - Developer Stories

## Results

Loading...
Summary: Inherited Constants | Fields | Methods | Inherited Methods | [Expand All]
public class

# Contents

extends Object
implements SafeParcelable

java.lang.Object
↳ | com.google.android.gms.drive.Contents

## Class Overview

A reference to a Drive file's contents. Any changes made to the FileDescriptor will be local to the app until close or create is called. Once closed you may no longer access the contents via this instance.

Specifically, if these contents refer to an existing file, call `commitAndCloseContents(GoogleApiClient, Contents)`. If these are new contents, provide them to create a new file programatically via `createFile(GoogleApiClient, MetadataChangeSet, Contents)` or set them as the initial contents in the create file dialog: `newCreateFileActivityBuilder()`.

## Summary

[Expand] Inherited Constants
From interface android.os.Parcelable
int | CONTENTS_FILE_DESCRIPTOR |
int | PARCELABLE_WRITE_RETURN_VALUE |
From interface com.google.android.gms.common.internal.safeparcel.SafeParcelable
String | NULL |

Fields
public static final Creator<Contents> | CREATOR |

Public Methods
int | describeContents()
DriveId | getDriveId() Gets the `DriveId` for the file that owns these contents.
InputStream | getInputStream() Gets an InputStream that allows you to read this file's contents.
int | getMode() Gets the mode the contents were opened in.
OutputStream | getOutputStream() Gets an OutputStream that allows you to write new contents.
ParcelFileDescriptor | getParcelFileDescriptor() Gets a FileDescriptor that points to the Drive file's contents.
void | writeToParcel(Parcel dest, int flags)

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
From interface android.os.Parcelable
abstract int | describeContents()
abstract void | writeToParcel(Parcel arg0, int arg1)

## Fields

#### public static final Creator<Contents> CREATOR

## Public Methods

#### public int describeContents ()

#### public DriveId getDriveId ()

Gets the `DriveId` for the file that owns these contents. Will be null if these are new contents.

#### public InputStream getInputStream ()

Gets an InputStream that allows you to read this file's contents. This method may only be used with files opened with `MODE_READ_ONLY`; to read/write from a file opened with `MODE_READ_WRITE`, use the file descriptor returned by `getParcelFileDescriptor()`. This method may only be called once per `Contents` instance.

#### public int getMode ()

Gets the mode the contents were opened in.

#### public OutputStream getOutputStream ()

Gets an OutputStream that allows you to write new contents. This method may only be used with files opened with `MODE_WRITE_ONLY`; to read/write from a file opened with `MODE_READ_WRITE`, use the file descriptor returned by `getParcelFileDescriptor()`. This method may only be called once per `Contents` instance.

#### public ParcelFileDescriptor getParcelFileDescriptor ()

Gets a FileDescriptor that points to the Drive file's contents. If this file was opened with `MODE_READ_ONLY` or `MODE_READ_WRITE`, the file referenced by the FileDescriptor will contain the most recent version of the file. Otherwise, the file will be empty.

#### public void writeToParcel (Parcel dest, int flags)