DataItem
Stay organized with collections
Save and categorize content based on your preferences.
The base object of data stored in the Android Wear network. DataItem
are
replicated across all devices in the network. It contains a small blob of data and associated Asset
s.
A DataItem
is
identified by its Uri, which contains its creator and a path.
Inherited Method Summary
From interface
com.google.android.gms.common.data.Freezable
Public Methods
public abstract byte[]
getData
()
An array of data stored at the specified Uri
. DataMapItem
may be used to store structured data in the network.
public abstract Uri
getUri
()
public abstract DataItem
setData
(byte[]
data)
Sets the data in a DataItem
.
The current maximum DataItem
size limit is approximately 100k. DataItem
s
should generally be much smaller than this limit.
Note: Use an empty array if there is no data to store. null
is only
allowed for backwards compatibility.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["\u003cp\u003e\u003ccode\u003eDataItem\u003c/code\u003e is the fundamental object for storing data within the Android Wear network, replicating across all connected devices.\u003c/p\u003e\n"],["\u003cp\u003eIt comprises a small data blob and related \u003ccode\u003eAsset\u003c/code\u003es, identifiable by a unique URI indicating its creator and path.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eDataItem\u003c/code\u003e provides methods to access and manipulate its associated data and assets, including \u003ccode\u003egetAssets()\u003c/code\u003e, \u003ccode\u003egetData()\u003c/code\u003e, \u003ccode\u003egetUri()\u003c/code\u003e, and \u003ccode\u003esetData()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eDataMapItem\u003c/code\u003e can be utilized to manage structured data and \u003ccode\u003eAsset\u003c/code\u003es within the \u003ccode\u003eDataItem\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe maximum size for a \u003ccode\u003eDataItem\u003c/code\u003e is around 100KB, although it is recommended to keep them considerably smaller.\u003c/p\u003e\n"]]],[],null,["# DataItem\n\npublic interface **DataItem** implements [Freezable](/android/reference/com/google/android/gms/common/data/Freezable)\\\u003c[DataItem](/android/reference/com/google/android/gms/wearable/DataItem)\\\u003e \nThe base object of data stored in the Android Wear network. [DataItem](/android/reference/com/google/android/gms/wearable/DataItem) are\nreplicated across all devices in the network. It contains a small blob of data and associated\n[Asset](/android/reference/com/google/android/gms/wearable/Asset)s.\n\nA [DataItem](/android/reference/com/google/android/gms/wearable/DataItem) is\nidentified by its Uri, which contains its creator and a path. \n\n##### See Also\n\n- [DataMapItem](/android/reference/com/google/android/gms/wearable/DataMapItem) \n\n### Public Method Summary\n\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Map](//developer.android.com/reference/java/util/Map.html)\\\u003c[String](//developer.android.com/reference/java/lang/String.html), [DataItemAsset](/android/reference/com/google/android/gms/wearable/DataItemAsset)\\\u003e | [getAssets](/android/reference/com/google/android/gms/wearable/DataItem#getAssets())() A map of [Asset](/android/reference/com/google/android/gms/wearable/Asset)s associated with this [DataItem](/android/reference/com/google/android/gms/wearable/DataItem). |\n| abstract byte\\[\\] | [getData](/android/reference/com/google/android/gms/wearable/DataItem#getData())() An array of data stored at the specified [Uri](//developer.android.com/reference/android/net/Uri.html). |\n| abstract [Uri](//developer.android.com/reference/android/net/Uri.html) | [getUri](/android/reference/com/google/android/gms/wearable/DataItem#getUri())() Returns the [DataItem](/android/reference/com/google/android/gms/wearable/DataItem)'s Uri. |\n| abstract [DataItem](/android/reference/com/google/android/gms/wearable/DataItem) | [setData](/android/reference/com/google/android/gms/wearable/DataItem#setData(byte[]))(byte\\[\\] data) Sets the data in a [DataItem](/android/reference/com/google/android/gms/wearable/DataItem). |\n\n### Inherited Method Summary\n\nFrom interface com.google.android.gms.common.data.Freezable \n\n|----------------------------------------------------------------------------------|---------------|\n| abstract [DataItem](/android/reference/com/google/android/gms/wearable/DataItem) | freeze() |\n| abstract boolean | isDataValid() |\n\nPublic Methods\n--------------\n\n#### public abstract [Map](//developer.android.com/reference/java/util/Map.html)\\\u003c[String](//developer.android.com/reference/java/lang/String.html), [DataItemAsset](/android/reference/com/google/android/gms/wearable/DataItemAsset)\\\u003e\n**getAssets** ()\n\nA map of [Asset](/android/reference/com/google/android/gms/wearable/Asset)s\nassociated with this [DataItem](/android/reference/com/google/android/gms/wearable/DataItem).\n[DataMapItem](/android/reference/com/google/android/gms/wearable/DataMapItem)\nmay be used to store structured data in the network, including [Asset](/android/reference/com/google/android/gms/wearable/Asset)s. \n\n#### public abstract byte\\[\\]\n**getData** ()\n\nAn array of data stored at the specified [Uri](//developer.android.com/reference/android/net/Uri.html). [DataMapItem](/android/reference/com/google/android/gms/wearable/DataMapItem)\nmay be used to store structured data in the network. \n\n#### public abstract [Uri](//developer.android.com/reference/android/net/Uri.html) **getUri** ()\n\nReturns the [DataItem](/android/reference/com/google/android/gms/wearable/DataItem)'s\nUri. [Uri.getHost()](//developer.android.com/reference/android/net/Uri.html#getHost())\nreturns the id of the node that created it. \n\n#### public abstract [DataItem](/android/reference/com/google/android/gms/wearable/DataItem)\n**setData** (byte\\[\\] data)\n\nSets the data in a [DataItem](/android/reference/com/google/android/gms/wearable/DataItem).\n\nThe current maximum [DataItem](/android/reference/com/google/android/gms/wearable/DataItem)\nsize limit is approximately 100k. [DataItem](/android/reference/com/google/android/gms/wearable/DataItem)s\nshould generally be much smaller than this limit.\n\nNote: Use an empty array if there is no data to store. `null` is only\nallowed for backwards compatibility."]]