Package android.os
Class PersistableBundle
- java.lang.Object
-
- android.os.BaseBundle
-
- android.os.PersistableBundle
-
- All Implemented Interfaces:
Parcelable,XmlUtils.WriteMapCallback,Cloneable
public final class PersistableBundle extends BaseBundle implements Cloneable, Parcelable, XmlUtils.WriteMapCallback
A mapping from String values to various types that can be saved to persistent and later restored.
-
-
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<PersistableBundle>CREATORstatic PersistableBundleEMPTY-
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
-
-
Constructor Summary
Constructors Constructor Description PersistableBundle()Constructs a new, empty PersistableBundle.PersistableBundle(int capacity)Constructs a new, empty PersistableBundle sized to hold the given number of elements.PersistableBundle(PersistableBundle b)Constructs a PersistableBundle containing a copy of the mappings from the given PersistableBundle.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectclone()Clones the current PersistableBundle.intdescribeContents()Report the nature of this Parcelable's contentsstatic PersistableBundleforPair(String key, String value)Make a PersistableBundle for a single key/value pair.PersistableBundlegetPersistableBundle(String key)Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.static booleanisValidType(Object value)voidputPersistableBundle(String key, PersistableBundle value)Inserts a PersistableBundle value into the mapping of this Bundle, replacing any existing value for the given key.static PersistableBundlerestoreFromXml(XmlPullParser in)voidsaveToXml(XmlSerializer out)StringtoString()Returns a string containing a concise, human-readable description of this object.voidwriteToParcel(Parcel parcel, int flags)Writes the PersistableBundle contents to a Parcel, typically in order for it to be passed through an IBinder connection.voidwriteUnknownObject(Object v, String name, XmlSerializer out)Called from writeMapXml when an Object type is not recognized.-
Methods inherited from class android.os.BaseBundle
clear, containsKey, get, getDouble, getDouble, getDoubleArray, getInt, getInt, getIntArray, getLong, getLong, getLongArray, getPairValue, getString, getString, getStringArray, isEmpty, isParcelled, keySet, putAll, putDouble, putDoubleArray, putInt, putIntArray, putLong, putLongArray, putString, putStringArray, remove, size
-
-
-
-
Field Detail
-
EMPTY
public static final PersistableBundle EMPTY
-
CREATOR
public static final Parcelable.Creator<PersistableBundle> CREATOR
-
-
Constructor Detail
-
PersistableBundle
public PersistableBundle()
Constructs a new, empty PersistableBundle.
-
PersistableBundle
public PersistableBundle(int capacity)
Constructs a new, empty PersistableBundle sized to hold the given number of elements. The PersistableBundle will grow as needed.- Parameters:
capacity- the initial capacity of the PersistableBundle
-
PersistableBundle
public PersistableBundle(PersistableBundle b)
Constructs a PersistableBundle containing a copy of the mappings from the given PersistableBundle.- Parameters:
b- a PersistableBundle to be copied.
-
-
Method Detail
-
isValidType
public static boolean isValidType(Object value)
-
forPair
public static PersistableBundle forPair(String key, String value)
Make a PersistableBundle for a single key/value pair.
-
clone
public Object clone()
Clones the current PersistableBundle. The internal map is cloned, but the keys and values to which it refers are copied by reference.
-
putPersistableBundle
public void putPersistableBundle(String key, PersistableBundle value)
Inserts a PersistableBundle value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.- Parameters:
key- a String, or nullvalue- a Bundle object, or null
-
getPersistableBundle
public PersistableBundle getPersistableBundle(String key)
Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.- Parameters:
key- a String, or null- Returns:
- a Bundle value, or null
-
writeUnknownObject
public void writeUnknownObject(Object v, String name, XmlSerializer out) throws XmlPullParserException, IOException
Description copied from interface:XmlUtils.WriteMapCallbackCalled from writeMapXml when an Object type is not recognized. The implementer must write out the entire element including start and end tags.- Specified by:
writeUnknownObjectin interfaceXmlUtils.WriteMapCallback- Parameters:
v- The object to be written outname- The mapping key for v. Must be written into the "name" attribute of the start tag.out- The XML output stream.- Throws:
XmlPullParserException- on unrecognized Object type.IOException- on XmlSerializer serialization errors.
-
saveToXml
public void saveToXml(XmlSerializer out) throws IOException, XmlPullParserException
- Throws:
IOExceptionXmlPullParserException
-
describeContents
public int describeContents()
Report the nature of this Parcelable's contents- 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)
Writes the PersistableBundle contents to a Parcel, typically in order for it to be passed through an IBinder connection.- Specified by:
writeToParcelin interfaceParcelable- Parameters:
parcel- The parcel to copy this bundle to.flags- Additional flags about how the object should be written. May be 0 orParcelable.PARCELABLE_WRITE_RETURN_VALUE.
-
restoreFromXml
public static PersistableBundle restoreFromXml(XmlPullParser in) throws IOException, XmlPullParserException
- Throws:
IOExceptionXmlPullParserException
-
toString
public String toString()
Description copied from class:ObjectReturns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:getClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toStringmethod if you intend implementing your owntoStringmethod.
-
-