CreateFileActivityBuilder | 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: Constants | Methods | Inherited Methods | [Expand All]
public class

# CreateFileActivityBuilder

extends Object

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

## Class Overview

A builder that is used to configure and display the create file activity. This dialog creates a new file in the user's drive with a destination and title selected by the user, and the initial metadata and contents specified in this builder. If the device is currently offline, the file will be created locally and committed to the server when connectivity is restored.

To create a new `DriveFile`, create a `Contents` object using `newContents(GoogleApiClient)` and use it to write the file content and `MetadataChangeSet.Builder` to create the associated metadata and set them on the builder using `setInitialContents(Contents)` and `setInitialMetadata(MetadataChangeSet)` before building.

To display the activity, pass the result of `build(GoogleApiClient)` to `#startActivityForResult()`. When the activity completes, a successful response will include an extra `EXTRA_RESPONSE_DRIVE_ID` that specifies the `DriveId` for the newly created file.

Note: you cannot use `#startActivity` to invoke the activity. This will fail.

## Summary

Constants
String | EXTRA_RESPONSE_DRIVE_ID | A successful result will return an extra by this name which will contain the `DriveId` of the created file.

Public Methods
IntentSender | build(GoogleApiClient apiClient) Gets an Intent that can be used to start the Create File activity.
CreateFileActivityBuilder | setActivityStartFolder(DriveId folder) Sets the default folder that will be presented at activity startup as the location for file creation.
CreateFileActivityBuilder | setActivityTitle(String title) Sets the title displayed in the activity.
CreateFileActivityBuilder | setInitialContents(Contents contents) Sets the initial contents for the new file.
CreateFileActivityBuilder | setInitialMetadata(MetadataChangeSet metadataChangeSet) Sets the initial metadata for the new file.

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

## Constants

#### public static final String EXTRA_RESPONSE_DRIVE_ID

A successful result will return an extra by this name which will contain the `DriveId` of the created file.

Constant Value: "response_drive_id"

## Public Methods

#### public IntentSender build (GoogleApiClient apiClient)

Gets an Intent that can be used to start the Create File activity. Note that you must start this activity with `startActivityForResult`, not `startActivity`. Once this is invoked, the provided contents are finalized and cannot be edited. To make additional edits, reopen the contents with the returned DriveId.

##### Parameters

apiClient | The `GoogleApiClient` to service the call. The client must be connected before invoking this method.

#### public CreateFileActivityBuilder setActivityStartFolder (DriveId folder)

Sets the default folder that will be presented at activity startup as the location for file creation. The activity supports navigation from this point to other folders. If not set, defaults to the root folder in the user's Drive.

#### public CreateFileActivityBuilder setActivityTitle (String title)

Sets the title displayed in the activity.

##### Parameters

title | the title to set on the activity (may not be null)

#### public CreateFileActivityBuilder setInitialContents (Contents contents)

Sets the initial contents for the new file. This will close the contents, and persist them as the initial contents for the file. To continue editing the contents, reopen them once the file has been created. If the file being creates is binary (the default type), this method must be called or the `build(GoogleApiClient)` method will fail. A new `Contents` object can be created using the API `newContents(GoogleApiClient)`.

#### public CreateFileActivityBuilder setInitialMetadata (MetadataChangeSet metadataChangeSet)

Sets the initial metadata for the new file. This method must be called or the `build(GoogleApiClient)` method will fail. A new `MetadataChangeSet` can be created using `MetadataChangeSet.Builder`.