Added in API level 21

PersistableBundle


class PersistableBundle : BaseBundle, Cloneable, Parcelable
kotlin.Any
   ↳ 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 equals(java.lang.Object) or hashCode().

Summary

Inherited constants
Public constructors

Constructs a new, empty PersistableBundle.

Constructs a new, empty PersistableBundle sized to hold the given number of elements.

Constructs a PersistableBundle containing a copy of the mappings from the given PersistableBundle.

Public methods
Any

Clones the current PersistableBundle.

PersistableBundle!

Make a deep copy of the given bundle.

Int

Report the nature of this Parcelable's contents

PersistableBundle?

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.

Unit

Inserts a PersistableBundle value into the mapping of this Bundle, replacing any existing value for the given key.

static PersistableBundle

Reads a PersistableBundle from an InputStream.

String

Returns a string representation of the PersistableBundle that may be suitable for debugging.

Unit
writeToParcel(parcel: Parcel, flags: Int)

Writes the PersistableBundle contents to a Parcel, typically in order for it to be passed through an IBinder connection.

Unit
writeToStream(outputStream: OutputStream)

Writes the content of the PersistableBundle to a OutputStream.

Inherited functions
Properties
static Parcelable.Creator<PersistableBundle!>

static PersistableBundle!

An unmodifiable PersistableBundle that is always empty.

Public constructors

PersistableBundle

Added in API level 21
PersistableBundle()

Constructs a new, empty PersistableBundle.

PersistableBundle

Added in API level 21
PersistableBundle(capacity: Int)

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

PersistableBundle

Added in API level 21
PersistableBundle(b: PersistableBundle!)

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

Public methods

clone

Added in API level 21
fun clone(): Any

Clones the current PersistableBundle. The internal map is cloned, but the keys and values to which it refers are copied by reference.

Return
Any a clone of this instance.
Exceptions
java.lang.CloneNotSupportedException if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.

deepCopy

Added in API level 26
fun deepCopy(): PersistableBundle!

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.

describeContents

Added in API level 21
fun describeContents(): Int

Report the nature of this Parcelable's contents

Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

getPersistableBundle

Added in API level 21
fun getPersistableBundle(key: String?): PersistableBundle?

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
Return
PersistableBundle? a Bundle value, or null

putPersistableBundle

Added in API level 21
fun putPersistableBundle(
    key: String?,
    value: PersistableBundle?
): Unit

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

Added in API level 30
static fun readFromStream(inputStream: InputStream): PersistableBundle

Reads a PersistableBundle from an InputStream.

The stream must be generated by writeToStream.

Parameters
inputStream InputStream: This value cannot be null.
Return
PersistableBundle This value cannot be null.

See Also

toString

Added in API level 21
fun toString(): String

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.

Return
String a string representation of the object.

writeToParcel

Added in API level 21
fun writeToParcel(
    parcel: Parcel,
    flags: Int
): Unit

Writes the PersistableBundle contents to a Parcel, typically in order for it to be passed through an IBinder connection.

Parameters
dest The Parcel in which the object should be written. This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES
parcel Parcel: The parcel to copy this bundle to.

writeToStream

Added in API level 30
fun writeToStream(outputStream: OutputStream): Unit

Writes the content of the PersistableBundle to a OutputStream.

The content can be read by a readFromStream.

Parameters
outputStream OutputStream: This value cannot be null.

See Also

Properties

CREATOR

Added in API level 21
static val CREATOR: Parcelable.Creator<PersistableBundle!>

EMPTY

Added in API level 21
static val EMPTY: PersistableBundle!

An unmodifiable PersistableBundle that is always empty.