PersistableBundle
public
final
class
PersistableBundle
extends BaseBundle
implements
Cloneable,
Parcelable
java.lang.Object | ||
↳ | android.os.BaseBundle | |
↳ | android.os.PersistableBundle |
A mapping from String keys to values of various types. The set of types supported by this class is purposefully restricted to simple objects that can safely be persisted to and restored from disk.
Warning: Note that PersistableBundle
is a lazy container and as such it does
NOT implement Object.equals(java.lang.Object)
or Object.hashCode()
.
See also:
Summary
Inherited constants |
---|
Fields | |
---|---|
public
static
final
Creator<PersistableBundle> |
CREATOR
|
public
static
final
PersistableBundle |
EMPTY
An unmodifiable |
Public constructors | |
---|---|
PersistableBundle()
Constructs a new, empty PersistableBundle. |
|
PersistableBundle(PersistableBundle b)
Constructs a PersistableBundle containing a copy of the mappings from the given PersistableBundle. |
|
PersistableBundle(int capacity)
Constructs a new, empty PersistableBundle sized to hold the given number of elements. |
Public methods | |
---|---|
Object
|
clone()
Clones the current PersistableBundle. |
PersistableBundle
|
deepCopy()
Make a deep copy of the given bundle. |
int
|
describeContents()
Report the nature of this Parcelable's contents |
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. |
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
|
readFromStream(InputStream inputStream)
Reads a |
String
|
toString()
Returns a string representation of the |
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
|
writeToStream(OutputStream outputStream)
Writes the content of the |
Inherited methods | |
---|---|
Fields
EMPTY
public static final PersistableBundle EMPTY
An unmodifiable PersistableBundle
that is always empty
.
Public constructors
PersistableBundle
public PersistableBundle ()
Constructs a new, empty PersistableBundle.
PersistableBundle
public PersistableBundle (PersistableBundle b)
Constructs a PersistableBundle containing a copy of the mappings from the given
PersistableBundle. Does only a shallow copy of the original PersistableBundle -- see
deepCopy()
if that is not what you want.
Parameters | |
---|---|
b |
PersistableBundle : a PersistableBundle to be copied. |
See also:
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 |
int : the initial capacity of the PersistableBundle |
Public methods
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.
Returns | |
---|---|
Object |
a clone of this instance. |
deepCopy
public PersistableBundle deepCopy ()
Make a deep copy of the given bundle. Traverses into inner containers and copies
them as well, so they are not shared across bundles. Will traverse in to
Bundle
, PersistableBundle
, ArrayList
, and all types of
primitive arrays. Other types of objects (such as Parcelable or Serializable)
are referenced as-is and not copied in any way.
Returns | |
---|---|
PersistableBundle |
describeContents
public int describeContents ()
Report the nature of this Parcelable's contents
Returns | |
---|---|
int |
a bitmask indicating the set of special object types marshaled
by this Parcelable object instance.
Value is either 0 or CONTENTS_FILE_DESCRIPTOR |
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 |
String : a String, or null |
Returns | |
---|---|
PersistableBundle |
a Bundle value, or null |
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 |
String : a String, or null |
value |
PersistableBundle : a Bundle object, or null |
readFromStream
public static PersistableBundle readFromStream (InputStream inputStream)
Reads a PersistableBundle
from an InputStream
.
The stream must be generated by writeToStream(OutputStream)
.
Parameters | |
---|---|
inputStream |
InputStream : This value cannot be null . |
Returns | |
---|---|
PersistableBundle |
This value cannot be null . |
Throws | |
---|---|
IOException |
See also:
toString
public String toString ()
Returns a string representation of the PersistableBundle
that may be suitable for
debugging. It won't print the internal map if its content hasn't been unparcelled.
Returns | |
---|---|
String |
a string representation of the object. |
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.
Parameters | |
---|---|
parcel |
Parcel : The parcel to copy this bundle to. |
flags |
int : Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE .
Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |
writeToStream
public void writeToStream (OutputStream outputStream)
Writes the content of the PersistableBundle
to a OutputStream
.
The content can be read by a readFromStream(InputStream)
.
Parameters | |
---|---|
outputStream |
OutputStream : This value cannot be null . |
Throws | |
---|---|
IOException |
See also: