public final class PersistableBundle extends BaseBundle implements Cloneable, Parcelable, XmlUtils.WriteMapCallback
Bundle
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<PersistableBundle> |
CREATOR |
static PersistableBundle |
EMPTY |
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
PersistableBundle()
Constructs a new, empty PersistableBundle.
|
PersistableBundle(Bundle b)
Constructs a PersistableBundle from a Bundle.
|
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.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Clones the current PersistableBundle.
|
int |
describeContents()
Report the nature of this Parcelable's contents
|
static PersistableBundle |
forPair(String key,
String value)
Make a PersistableBundle for a single key/value pair.
|
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.
|
static boolean |
isValidType(Object value) |
void |
putPersistableBundle(String key,
PersistableBundle value)
Inserts a PersistableBundle value into the mapping of this Bundle, replacing
any existing value for the given key.
|
static PersistableBundle |
restoreFromXml(XmlPullParser in) |
void |
saveToXml(XmlSerializer out) |
String |
toString()
Returns a string representation of the object.
|
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.
|
void |
writeUnknownObject(Object v,
String name,
XmlSerializer out)
Called from writeMapXml when an Object type is not recognized.
|
clear, containsKey, get, getBoolean, getBoolean, getBooleanArray, getDouble, getDouble, getDoubleArray, getInt, getInt, getIntArray, getLong, getLong, getLongArray, getPairValue, getString, getString, getStringArray, isEmpty, isEmptyParcel, isParcelled, keySet, putAll, putBoolean, putBooleanArray, putDouble, putDoubleArray, putInt, putIntArray, putLong, putLongArray, putString, putStringArray, remove, setShouldDefuse, size
public static final PersistableBundle EMPTY
public static final Parcelable.Creator<PersistableBundle> CREATOR
public PersistableBundle()
public PersistableBundle(int capacity)
capacity
- the initial capacity of the PersistableBundlepublic PersistableBundle(PersistableBundle b)
b
- a PersistableBundle to be copied.public PersistableBundle(Bundle b)
b
- a Bundle to be copied.IllegalArgumentException
- if any element of b
cannot be persisted.public static boolean isValidType(Object value)
public static PersistableBundle forPair(String key, String value)
public Object clone()
public void putPersistableBundle(String key, PersistableBundle value)
key
- a String, or nullvalue
- a Bundle object, or nullpublic PersistableBundle getPersistableBundle(String key)
key
- a String, or nullpublic void writeUnknownObject(Object v, String name, XmlSerializer out) throws XmlPullParserException, IOException
XmlUtils.WriteMapCallback
writeUnknownObject
in interface XmlUtils.WriteMapCallback
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.XmlPullParserException
- on unrecognized Object type.IOException
- on XmlSerializer serialization errors.public void saveToXml(XmlSerializer out) throws IOException, XmlPullParserException
IOException
XmlPullParserException
public int describeContents()
describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel parcel, int flags)
writeToParcel
in interface Parcelable
parcel
- The parcel to copy this bundle to.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.public static PersistableBundle restoreFromXml(XmlPullParser in) throws IOException, XmlPullParserException
IOException
XmlPullParserException
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())