FileUploadPreferences | 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
  - Analyze
  - Tools & Reference
  - Developer Stories

## Results

Loading...
public interface

# FileUploadPreferences

com.google.android.gms.drive.FileUploadPreferences

## Class Overview

Represents the file upload preferences associated with the current account. The preferences set by these APIs are applied only to the current user account and the calling application.

For example, the preference values for the file upload operations of the calling application can be fetched using `getFileUploadPreferences(GoogleApiClient)`. These preference values can be modified using `setNetworkTypePreference(int)`, `setRoamingAllowed(boolean)` or `setBatteryUsagePreference(int)` and then saved by executing the `setFileUploadPreferences(GoogleApiClient, FileUploadPreferences)` method.

## Summary

Constants
int | BATTERY_USAGE_CHARGING_ONLY | This value signifies that the operations by the calling application are allowed only when the device is plugged into a power source.
int | BATTERY_USAGE_UNRESTRICTED | This value signifies that the operations by the calling application are allowed immediately without being restricted on the current battery status of the device.
int | NETWORK_TYPE_ANY | This value signifies that the operations by the calling application are not restricted to any specific network type and can be applied over any available network connection (i.e.
int | NETWORK_TYPE_WIFI_ONLY | This value signifies that the operations by the calling application are allowed only over a WIFI network connection.
int | PREFERENCE_VALUE_UNKNOWN | This value signifies that the preference value is unknown to the calling application.

Public Methods
abstract int | getBatteryUsagePreference() Returns the current battery usage preference value.
abstract int | getNetworkTypePreference() Returns the current network type preference value.
abstract boolean | isRoamingAllowed() Returns the current roaming preference value.
abstract void | setBatteryUsagePreference(int batteryUsagePreference) Sets the battery usage preference to be applied on operations performed by the calling application.
abstract void | setNetworkTypePreference(int networkTypePreference) Sets the network type preference to be applied on operations performed by the calling application.
abstract void | setRoamingAllowed(boolean allowRoaming) Sets whether the operations by the calling application are allowed while the device is on roaming.

## Constants

#### public static final int BATTERY_USAGE_CHARGING_ONLY

This value signifies that the operations by the calling application are allowed only when the device is plugged into a power source. Note that this restriction is applied in addition to the network type preferences, see `getNetworkTypePreference()`.

Constant Value: 257 (0x00000101)

#### public static final int BATTERY_USAGE_UNRESTRICTED

This value signifies that the operations by the calling application are allowed immediately without being restricted on the current battery status of the device. Note that this restriction is applied in addition to the network type preferences, see `getNetworkTypePreference()`.

Constant Value: 256 (0x00000100)

#### public static final int NETWORK_TYPE_ANY

This value signifies that the operations by the calling application are not restricted to any specific network type and can be applied over any available network connection (i.e. WIFI, mobile data etc). Note that this restriction is applied in addition to the battery usage preferences, see `getBatteryUsagePreference()`.

Constant Value: 1 (0x00000001)

#### public static final int NETWORK_TYPE_WIFI_ONLY

This value signifies that the operations by the calling application are allowed only over a WIFI network connection. Note that this restriction is applied in addition to the battery usage preferences, see `getBatteryUsagePreference()`.

Constant Value: 2 (0x00000002)

#### public static final int PREFERENCE_VALUE_UNKNOWN

This value signifies that the preference value is unknown to the calling application. This value is returned only in the case when the preference is set to a value not available in this version of the API but is added in a newer version of the API. It is advised to update to the latest version of the API to get an appropriate preference value.

Constant Value: 0 (0x00000000)

## Public Methods

#### public abstract int getBatteryUsagePreference ()

Returns the current battery usage preference value. This value can be one of the following:

- `BATTERY_USAGE_UNRESTRICTED`
- `BATTERY_USAGE_CHARGING_ONLY`
- `PREFERENCE_VALUE_UNKNOWN`

The default value for this preference is `BATTERY_USAGE_UNRESTRICTED`.

Note: The value `PREFERENCE_VALUE_UNKNOWN` will be returned only in the case when the preference is set to a value not available in this version of the API but is added in a newer version of the API. It is advised to update to the latest version of the API to get an appropriate preference value.

#### public abstract int getNetworkTypePreference ()

Returns the current network type preference value. This value can be one of the following:

- `NETWORK_TYPE_ANY`
- `NETWORK_TYPE_WIFI_ONLY`
- `PREFERENCE_VALUE_UNKNOWN`

The default value for this preference is `NETWORK_TYPE_ANY`.

Note: The value `PREFERENCE_VALUE_UNKNOWN` will be returned only in the case when the preference is set to a value not available in this version of the API but is added in a newer version of the API. It is advised to update to the latest version of the API to get an appropriate preference value.

#### public abstract boolean isRoamingAllowed ()

Returns the current roaming preference value. If `true`, operations performed by the calling application are allowed while the device is on data roaming, otherwise not. The default value for this preference is `true`.

#### public abstract void setBatteryUsagePreference (int batteryUsagePreference)

Sets the battery usage preference to be applied on operations performed by the calling application. The following battery usage preference values are allowed:

- `BATTERY_USAGE_UNRESTRICTED`
- `BATTERY_USAGE_CHARGING_ONLY`

The preference value is only saved when `setFileUploadPreferences(GoogleApiClient, FileUploadPreferences)` is called.

##### Throws

IllegalArgumentException | if the input is an invalid preference value.

#### public abstract void setNetworkTypePreference (int networkTypePreference)

Sets the network type preference to be applied on operations performed by the calling application. The following network type preference values are allowed:

- `NETWORK_TYPE_ANY`
- `NETWORK_TYPE_WIFI_ONLY`

The preference value is only saved when `setFileUploadPreferences(GoogleApiClient, FileUploadPreferences)` is called.

Note that this value does not override the system level data usage preferences (https://support.google.com/nexus/answer/2819524) that the user might have set on their devices, i.e. if mobile data is disabled in the system settings, the file uploads will not happen on mobile network connection even if the file upload preference is set to `NETWORK_TYPE_ANY`. However, if mobile data is enabled the value set in this preference will be respected.

##### Throws

IllegalArgumentException | if the input is an invalid preference value.

#### public abstract void setRoamingAllowed (boolean allowRoaming)

Sets whether the operations by the calling application are allowed while the device is on roaming. The preference value is only saved when `setFileUploadPreferences(GoogleApiClient, FileUploadPreferences)` is called.

Note that this value does not override the system level data usage preferences (https://support.google.com/nexus/answer/2819524) that the user might have set on their devices, i.e. if data roaming is disabled in the system setting, the file uploads will not be allowed in roaming even if this preference is set to true. However if roaming is enabled, this preference will be respected.