DataApi | 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...
public interface

# DataApi

com.google.android.gms.wearable.DataApi

## Class Overview

Exposes an API for components to read or write `DataItem`s and `Asset`s.

A `DataItem` is synchronized across all devices in an Android Wear network. DataItems should generally be smaller in size, relying on `Asset`s for the storage of larger, more persistent data objects such as images.

`DataItem`s are identified by a Uri, accessible with `getUri()` that indicates the item's creator and path.

A `DataItem` is private to the application that created it and accessibly only by that application on other nodes.

## Summary

Nested Classes
interface | DataApi.DataItemResult | Contains a single data item.
interface | DataApi.DataListener | Used with `addListener(GoogleApiClient, DataApi.DataListener)` to receive data events.
interface | DataApi.DeleteDataItemsResult | Contains the number of deleted items.
interface | DataApi.GetFdForAssetResult | Contains a file descriptor for the requested asset.

Public Methods
abstract PendingResult<Status> | addListener(GoogleApiClient client, DataApi.DataListener listener) Registers a listener to receive data item changed and deleted events.
abstract PendingResult<DataApi.DeleteDataItemsResult> | deleteDataItems(GoogleApiClient client, Uri uri) Removes all specified `DataItem`s from the Android Wear network.
abstract PendingResult<DataApi.DataItemResult> | getDataItem(GoogleApiClient client, Uri uri) Retrieves a single `DataItem` from the Android Wear network.
abstract PendingResult<DataItemBuffer> | getDataItems(GoogleApiClient client) Retrieves all `DataItem`s from the Android Wear network.
abstract PendingResult<DataItemBuffer> | getDataItems(GoogleApiClient client, Uri uri) Retrieves all `DataItem`s matching the provided Uri, from the Android Wear network.
abstract PendingResult<DataApi.GetFdForAssetResult> | getFdForAsset(GoogleApiClient client, DataItemAsset asset) Retrieves a `ParcelFileDescriptor` pointing at the bytes of an asset.
abstract PendingResult<DataApi.GetFdForAssetResult> | getFdForAsset(GoogleApiClient client, Asset asset) Retrieves a `ParcelFileDescriptor` pointing at the bytes of an asset.
abstract PendingResult<DataApi.DataItemResult> | putDataItem(GoogleApiClient client, PutDataRequest request) Adds `DataItem` to the Android Wear network.
abstract PendingResult<Status> | removeListener(GoogleApiClient client, DataApi.DataListener listener) Removes a data listener.

## Public Methods

#### public abstract PendingResult<Status> addListener (GoogleApiClient client, DataApi.DataListener listener)

Registers a listener to receive data item changed and deleted events.

#### public abstract PendingResult<DataApi.DeleteDataItemsResult> deleteDataItems (GoogleApiClient client, Uri uri)

Removes all specified `DataItem`s from the Android Wear network.

Using glob uri selectors will allow this call to delete multiple data items at once.

#### public abstract PendingResult<DataApi.DataItemResult> getDataItem (GoogleApiClient client, Uri uri)

Retrieves a single `DataItem` from the Android Wear network. A fully qualified Uri must be specified. The uri's host must be a node that created the item.

#### public abstract PendingResult<DataItemBuffer> getDataItems (GoogleApiClient client)

Retrieves all `DataItem`s from the Android Wear network.

Callers should call `release()` when finished processing results.

#### public abstract PendingResult<DataItemBuffer> getDataItems (GoogleApiClient client, Uri uri)

Retrieves all `DataItem`s matching the provided Uri, from the Android Wear network. The Uri should contain a path, if the host is elided, all data items matching that path are returned.

Callers should call `release()` when finished processing results.

#### public abstract PendingResult<DataApi.GetFdForAssetResult> getFdForAsset (GoogleApiClient client, DataItemAsset asset)

Retrieves a `ParcelFileDescriptor` pointing at the bytes of an asset. Only assets previously stored in a `DataItem` may be retrieved.

#### public abstract PendingResult<DataApi.GetFdForAssetResult> getFdForAsset (GoogleApiClient client, Asset asset)

Retrieves a `ParcelFileDescriptor` pointing at the bytes of an asset. Only assets previously stored in a `DataItem` may be retrieved.

#### public abstract PendingResult<DataApi.DataItemResult> putDataItem (GoogleApiClient client, PutDataRequest request)

Adds `DataItem` to the Android Wear network. The updated item is synchronized across all devices.

#### public abstract PendingResult<Status> removeListener (GoogleApiClient client, DataApi.DataListener listener)

Removes a data listener.