Skip to content

Most visited

Recently visited

navigation
Added in API level 1

ContentValues

public final class ContentValues
extends Object implements Parcelable

java.lang.Object
   ↳ android.content.ContentValues


This class is used to store a set of values that the ContentResolver can process.

Summary

Constants

String TAG

Inherited constants

From interface android.os.Parcelable

Fields

public static final Creator<ContentValues> CREATOR

Public constructors

ContentValues()

Creates an empty set of values using the default initial size

ContentValues(int size)

Creates an empty set of values using the given initial size

ContentValues(ContentValues from)

Creates a set of values copied from the given set

Public methods

void clear()

Removes all values.

boolean containsKey(String key)

Returns true if this object has the named value.

int describeContents()

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

boolean equals(Object object)

Compares this instance with the specified object and indicates if they are equal.

Object get(String key)

Gets a value.

Boolean getAsBoolean(String key)

Gets a value and converts it to a Boolean.

Byte getAsByte(String key)

Gets a value and converts it to a Byte.

byte[] getAsByteArray(String key)

Gets a value that is a byte array.

Double getAsDouble(String key)

Gets a value and converts it to a Double.

Float getAsFloat(String key)

Gets a value and converts it to a Float.

Integer getAsInteger(String key)

Gets a value and converts it to an Integer.

Long getAsLong(String key)

Gets a value and converts it to a Long.

Short getAsShort(String key)

Gets a value and converts it to a Short.

String getAsString(String key)

Gets a value and converts it to a String.

int hashCode()

Returns an integer hash code for this object.

Set<String> keySet()

Returns a set of all of the keys

void put(String key, Byte value)

Adds a value to the set.

void put(String key, Integer value)

Adds a value to the set.

void put(String key, Float value)

Adds a value to the set.

void put(String key, Short value)

Adds a value to the set.

void put(String key, byte[] value)

Adds a value to the set.

void put(String key, String value)

Adds a value to the set.

void put(String key, Double value)

Adds a value to the set.

void put(String key, Long value)

Adds a value to the set.

void put(String key, Boolean value)

Adds a value to the set.

void putAll(ContentValues other)

Adds all values from the passed in ContentValues.

void putNull(String key)

Adds a null value to the set.

void remove(String key)

Remove a single value.

int size()

Returns the number of values.

String toString()

Returns a string containing a concise, human-readable description of this object.

Set<Entry<StringObject>> valueSet()

Returns a set of all of the keys and values

void writeToParcel(Parcel parcel, int flags)

Flatten this object in to a Parcel.

Inherited methods

From class java.lang.Object
From interface android.os.Parcelable

Constants

TAG

Added in API level 1
String TAG

Constant Value: "ContentValues"

Fields

CREATOR

Added in API level 1
Creator<ContentValues> CREATOR

Public constructors

ContentValues

Added in API level 1
ContentValues ()

Creates an empty set of values using the default initial size

ContentValues

Added in API level 1
ContentValues (int size)

Creates an empty set of values using the given initial size

Parameters
size int: the initial size of the set of values

ContentValues

Added in API level 1
ContentValues (ContentValues from)

Creates a set of values copied from the given set

Parameters
from ContentValues: the values to copy

Public methods

clear

Added in API level 1
void clear ()

Removes all values.

containsKey

Added in API level 1
boolean containsKey (String key)

Returns true if this object has the named value.

Parameters
key String: the value to check for
Returns
boolean true if the value is present, false otherwise

describeContents

Added in API level 1
int describeContents ()

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Returns
int a bitmask indicating the set of special object types marshalled by the Parcelable.

equals

Added in API level 1
boolean equals (Object object)

Compares this instance with the specified object and indicates if they are equal. In order to be equal, o must represent the same object as this instance using a class-specific comparison. The general contract is that this comparison should be reflexive, symmetric, and transitive. Also, no object reference other than null is equal to null.

The default implementation returns true only if this == o. See Writing a correct equals method if you intend implementing your own equals method.

The general contract for the equals and hashCode() methods is that if equals returns true for any two objects, then hashCode() must return the same value for these objects. This means that subclasses of Object usually override either both methods or neither of them.

Parameters
object Object: the object to compare this instance with.
Returns
boolean true if the specified object is equal to this Object; false otherwise.

get

Added in API level 1
Object get (String key)

Gets a value. Valid value types are String, Boolean, and Number implementations.

Parameters
key String: the value to get
Returns
Object the data for the value

getAsBoolean

Added in API level 1
Boolean getAsBoolean (String key)

Gets a value and converts it to a Boolean.

Parameters
key String: the value to get
Returns
Boolean the Boolean value, or null if the value is missing or cannot be converted

getAsByte

Added in API level 1
Byte getAsByte (String key)

Gets a value and converts it to a Byte.

Parameters
key String: the value to get
Returns
Byte the Byte value, or null if the value is missing or cannot be converted

getAsByteArray

Added in API level 1
byte[] getAsByteArray (String key)

Gets a value that is a byte array. Note that this method will not convert any other types to byte arrays.

Parameters
key String: the value to get
Returns
byte[] the byte[] value, or null is the value is missing or not a byte[]

getAsDouble

Added in API level 1
Double getAsDouble (String key)

Gets a value and converts it to a Double.

Parameters
key String: the value to get
Returns
Double the Double value, or null if the value is missing or cannot be converted

getAsFloat

Added in API level 1
Float getAsFloat (String key)

Gets a value and converts it to a Float.

Parameters
key String: the value to get
Returns
Float the Float value, or null if the value is missing or cannot be converted

getAsInteger

Added in API level 1
Integer getAsInteger (String key)

Gets a value and converts it to an Integer.

Parameters
key String: the value to get
Returns
Integer the Integer value, or null if the value is missing or cannot be converted

getAsLong

Added in API level 1
Long getAsLong (String key)

Gets a value and converts it to a Long.

Parameters
key String: the value to get
Returns
Long the Long value, or null if the value is missing or cannot be converted

getAsShort

Added in API level 1
Short getAsShort (String key)

Gets a value and converts it to a Short.

Parameters
key String: the value to get
Returns
Short the Short value, or null if the value is missing or cannot be converted

getAsString

Added in API level 1
String getAsString (String key)

Gets a value and converts it to a String.

Parameters
key String: the value to get
Returns
String the String for the value

hashCode

Added in API level 1
int hashCode ()

Returns an integer hash code for this object. By contract, any two objects for which equals(Object) returns true must return the same hash code value. This means that subclasses of Object usually override both methods or neither method.

Note that hash values must not change over time unless information used in equals comparisons also changes.

See Writing a correct hashCode method if you intend implementing your own hashCode method.

Returns
int this object's hash code.

keySet

Added in API level 11
Set<String> keySet ()

Returns a set of all of the keys

Returns
Set<String> a set of all of the keys

put

Added in API level 1
void put (String key, 
                Byte value)

Adds a value to the set.

Parameters
key String: the name of the value to put
value Byte: the data for the value to put

put

Added in API level 1
void put (String key, 
                Integer value)

Adds a value to the set.

Parameters
key String: the name of the value to put
value Integer: the data for the value to put

put

Added in API level 1
void put (String key, 
                Float value)

Adds a value to the set.

Parameters
key String: the name of the value to put
value Float: the data for the value to put

put

Added in API level 1
void put (String key, 
                Short value)

Adds a value to the set.

Parameters
key String: the name of the value to put
value Short: the data for the value to put

put

Added in API level 1
void put (String key, 
                byte[] value)

Adds a value to the set.

Parameters
key String: the name of the value to put
value byte: the data for the value to put

put

Added in API level 1
void put (String key, 
                String value)

Adds a value to the set.

Parameters
key String: the name of the value to put
value String: the data for the value to put

put

Added in API level 1
void put (String key, 
                Double value)

Adds a value to the set.

Parameters
key String: the name of the value to put
value Double: the data for the value to put

put

Added in API level 1
void put (String key, 
                Long value)

Adds a value to the set.

Parameters
key String: the name of the value to put
value Long: the data for the value to put

put

Added in API level 1
void put (String key, 
                Boolean value)

Adds a value to the set.

Parameters
key String: the name of the value to put
value Boolean: the data for the value to put

putAll

Added in API level 1
void putAll (ContentValues other)

Adds all values from the passed in ContentValues.

Parameters
other ContentValues: the ContentValues from which to copy

putNull

Added in API level 1
void putNull (String key)

Adds a null value to the set.

Parameters
key String: the name of the value to make null

remove

Added in API level 1
void remove (String key)

Remove a single value.

Parameters
key String: the name of the value to remove

size

Added in API level 1
int size ()

Returns the number of values.

Returns
int the number of values

toString

Added in API level 1
String toString ()

Returns a string containing a concise, human-readable description of this object.

Returns
String a printable representation of this object.

valueSet

Added in API level 1
Set<Entry<StringObject>> valueSet ()

Returns a set of all of the keys and values

Returns
Set<Entry<StringObject>> a set of all of the keys and values

writeToParcel

Added in API level 1
void writeToParcel (Parcel parcel, 
                int flags)

Flatten this object in to a Parcel.

Parameters
parcel Parcel: The Parcel in which the object should be written.
flags int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.