Package android.content
Class ContentValues
- java.lang.Object
-
- android.content.ContentValues
-
- All Implemented Interfaces:
Parcelable
public final class ContentValues extends Object implements Parcelable
This class is used to store a set of values that theContentResolvercan process.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface android.os.Parcelable
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
-
-
Field Summary
Fields Modifier and Type Field Description static Parcelable.Creator<ContentValues>CREATORstatic StringTAG-
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
-
-
Constructor Summary
Constructors Constructor Description ContentValues()Creates an empty set of values using the default initial sizeContentValues(int size)Creates an empty set of values using the given initial sizeContentValues(ContentValues from)Creates a set of values copied from the given set
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclear()Removes all values.booleancontainsKey(String key)Returns true if this object has the named value.intdescribeContents()Describe the kinds of special objects contained in this Parcelable's marshalled representation.booleanequals(Object object)Compares this instance with the specified object and indicates if they are equal.Objectget(String key)Gets a value.BooleangetAsBoolean(String key)Gets a value and converts it to a Boolean.BytegetAsByte(String key)Gets a value and converts it to a Byte.byte[]getAsByteArray(String key)Gets a value that is a byte array.DoublegetAsDouble(String key)Gets a value and converts it to a Double.FloatgetAsFloat(String key)Gets a value and converts it to a Float.IntegergetAsInteger(String key)Gets a value and converts it to an Integer.LonggetAsLong(String key)Gets a value and converts it to a Long.ShortgetAsShort(String key)Gets a value and converts it to a Short.StringgetAsString(String key)Gets a value and converts it to a String.ArrayList<String>getStringArrayList(String key)Deprecated.inthashCode()Returns an integer hash code for this object.Set<String>keySet()Returns a set of all of the keysvoidput(String key, byte[] value)Adds a value to the set.voidput(String key, Boolean value)Adds a value to the set.voidput(String key, Byte value)Adds a value to the set.voidput(String key, Double value)Adds a value to the set.voidput(String key, Float value)Adds a value to the set.voidput(String key, Integer value)Adds a value to the set.voidput(String key, Long value)Adds a value to the set.voidput(String key, Short value)Adds a value to the set.voidput(String key, String value)Adds a value to the set.voidputAll(ContentValues other)Adds all values from the passed in ContentValues.voidputNull(String key)Adds a null value to the set.voidputStringArrayList(String key, ArrayList<String> value)Deprecated.voidremove(String key)Remove a single value.intsize()Returns the number of values.StringtoString()Returns a string containing a concise, human-readable description of this object.Set<Map.Entry<String,Object>>valueSet()Returns a set of all of the keys and valuesvoidwriteToParcel(Parcel parcel, int flags)Flatten this object in to a Parcel.
-
-
-
Field Detail
-
TAG
public static final String TAG
- See Also:
- Constant Field Values
-
CREATOR
public static final Parcelable.Creator<ContentValues> CREATOR
-
-
Constructor Detail
-
ContentValues
public ContentValues()
Creates an empty set of values using the default initial size
-
ContentValues
public ContentValues(int size)
Creates an empty set of values using the given initial size- Parameters:
size- the initial size of the set of values
-
ContentValues
public ContentValues(ContentValues from)
Creates a set of values copied from the given set- Parameters:
from- the values to copy
-
-
Method Detail
-
equals
public boolean equals(Object object)
Description copied from class:ObjectCompares this instance with the specified object and indicates if they are equal. In order to be equal,omust 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
trueonly ifthis == o. See Writing a correctequalsmethod if you intend implementing your ownequalsmethod.The general contract for the
equalsandObject.hashCode()methods is that ifequalsreturnstruefor any two objects, thenhashCode()must return the same value for these objects. This means that subclasses ofObjectusually override either both methods or neither of them.- Overrides:
equalsin classObject- Parameters:
object- the object to compare this instance with.- Returns:
trueif the specified object is equal to thisObject;falseotherwise.- See Also:
Object.hashCode()
-
hashCode
public int hashCode()
Description copied from class:ObjectReturns an integer hash code for this object. By contract, any two objects for whichObject.equals(java.lang.Object)returnstruemust return the same hash code value. This means that subclasses ofObjectusually 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
hashCodemethod if you intend implementing your ownhashCodemethod.- Overrides:
hashCodein classObject- Returns:
- this object's hash code.
- See Also:
Object.equals(java.lang.Object)
-
put
public void put(String key, String value)
Adds a value to the set.- Parameters:
key- the name of the value to putvalue- the data for the value to put
-
putAll
public void putAll(ContentValues other)
Adds all values from the passed in ContentValues.- Parameters:
other- the ContentValues from which to copy
-
put
public void put(String key, Byte value)
Adds a value to the set.- Parameters:
key- the name of the value to putvalue- the data for the value to put
-
put
public void put(String key, Short value)
Adds a value to the set.- Parameters:
key- the name of the value to putvalue- the data for the value to put
-
put
public void put(String key, Integer value)
Adds a value to the set.- Parameters:
key- the name of the value to putvalue- the data for the value to put
-
put
public void put(String key, Long value)
Adds a value to the set.- Parameters:
key- the name of the value to putvalue- the data for the value to put
-
put
public void put(String key, Float value)
Adds a value to the set.- Parameters:
key- the name of the value to putvalue- the data for the value to put
-
put
public void put(String key, Double value)
Adds a value to the set.- Parameters:
key- the name of the value to putvalue- the data for the value to put
-
put
public void put(String key, Boolean value)
Adds a value to the set.- Parameters:
key- the name of the value to putvalue- the data for the value to put
-
put
public void put(String key, byte[] value)
Adds a value to the set.- Parameters:
key- the name of the value to putvalue- the data for the value to put
-
putNull
public void putNull(String key)
Adds a null value to the set.- Parameters:
key- the name of the value to make null
-
size
public int size()
Returns the number of values.- Returns:
- the number of values
-
remove
public void remove(String key)
Remove a single value.- Parameters:
key- the name of the value to remove
-
clear
public void clear()
Removes all values.
-
containsKey
public boolean containsKey(String key)
Returns true if this object has the named value.- Parameters:
key- the value to check for- Returns:
trueif the value is present,falseotherwise
-
get
public Object get(String key)
- Parameters:
key- the value to get- Returns:
- the data for the value
-
getAsString
public String getAsString(String key)
Gets a value and converts it to a String.- Parameters:
key- the value to get- Returns:
- the String for the value
-
getAsLong
public Long getAsLong(String key)
Gets a value and converts it to a Long.- Parameters:
key- the value to get- Returns:
- the Long value, or null if the value is missing or cannot be converted
-
getAsInteger
public Integer getAsInteger(String key)
Gets a value and converts it to an Integer.- Parameters:
key- the value to get- Returns:
- the Integer value, or null if the value is missing or cannot be converted
-
getAsShort
public Short getAsShort(String key)
Gets a value and converts it to a Short.- Parameters:
key- the value to get- Returns:
- the Short value, or null if the value is missing or cannot be converted
-
getAsByte
public Byte getAsByte(String key)
Gets a value and converts it to a Byte.- Parameters:
key- the value to get- Returns:
- the Byte value, or null if the value is missing or cannot be converted
-
getAsDouble
public Double getAsDouble(String key)
Gets a value and converts it to a Double.- Parameters:
key- the value to get- Returns:
- the Double value, or null if the value is missing or cannot be converted
-
getAsFloat
public Float getAsFloat(String key)
Gets a value and converts it to a Float.- Parameters:
key- the value to get- Returns:
- the Float value, or null if the value is missing or cannot be converted
-
getAsBoolean
public Boolean getAsBoolean(String key)
Gets a value and converts it to a Boolean.- Parameters:
key- the value to get- Returns:
- the Boolean value, or null if the value is missing or cannot be converted
-
getAsByteArray
public 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- the value to get- Returns:
- the byte[] value, or null is the value is missing or not a byte[]
-
valueSet
public Set<Map.Entry<String,Object>> valueSet()
Returns a set of all of the keys and values- Returns:
- a set of all of the keys and values
-
keySet
public Set<String> keySet()
Returns a set of all of the keys- Returns:
- a set of all of the keys
-
describeContents
public int describeContents()
Description copied from interface:ParcelableDescribe the kinds of special objects contained in this Parcelable's marshalled representation.- Specified by:
describeContentsin interfaceParcelable- Returns:
- a bitmask indicating the set of special object types marshalled by the Parcelable.
-
writeToParcel
public void writeToParcel(Parcel parcel, int flags)
Description copied from interface:ParcelableFlatten this object in to a Parcel.- Specified by:
writeToParcelin interfaceParcelable- Parameters:
parcel- The Parcel in which the object should be written.flags- Additional flags about how the object should be written. May be 0 orParcelable.PARCELABLE_WRITE_RETURN_VALUE.
-
putStringArrayList
@Deprecated public void putStringArrayList(String key, ArrayList<String> value)
Deprecated.Unsupported, here until we get proper bulk insert APIs.
-
getStringArrayList
@Deprecated public ArrayList<String> getStringArrayList(String key)
Deprecated.Unsupported, here until we get proper bulk insert APIs.
-
-