Data

public final class Data
extends Object

java.lang.Object
   ↳ androidx.work.Data


A persistable set of key/value pairs which are used as inputs and outputs for ListenableWorkers. Keys are Strings, and values can be Strings, primitive types, or their array variants.

This is a lightweight container, and should not be considered your data store. As such, there is an enforced MAX_DATA_BYTES limit on the serialized (byte array) size of the payloads. This class will throw IllegalStateExceptions if you try to serialize or deserialize past this limit.

Summary

Nested classes

class Data.Builder

A builder for Data objects. 

Constants

int MAX_DATA_BYTES

The maximum number of bytes for Data when it is serialized (converted to a byte array).

Fields

public static final Data EMPTY

An empty Data object with no elements.

Public constructors

Data(Data other)

Public methods

boolean equals(Object o)
static Data fromByteArray(byte[] bytes)

Converts a byte array to Data.

boolean getBoolean(String key, boolean defaultValue)

Gets the boolean value for the given key.

boolean[] getBooleanArray(String key)

Gets the boolean array value for the given key.

byte getByte(String key, byte defaultValue)

Gets the byte value for the given key.

byte[] getByteArray(String key)

Gets the byte array value for the given key.

double getDouble(String key, double defaultValue)

Gets the double value for the given key.

double[] getDoubleArray(String key)

Gets the double array value for the given key.

float getFloat(String key, float defaultValue)

Gets the float value for the given key.

float[] getFloatArray(String key)

Gets the float array value for the given key.

int getInt(String key, int defaultValue)

Gets the integer value for the given key.

int[]