# PersistableBundle

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Inherited Constants](https://developer.android.com/reference/android/os/PersistableBundle#inhconstants)\|[Fields](https://developer.android.com/reference/android/os/PersistableBundle#lfields)\|[Ctors](https://developer.android.com/reference/android/os/PersistableBundle#pubctors)\|[Methods](https://developer.android.com/reference/android/os/PersistableBundle#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/os/PersistableBundle#inhmethods)  

# PersistableBundle

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/os/PersistableBundle "View this page in Kotlin")\|Java

`
public

final

class
PersistableBundle
`  
`


``

extends `[BaseBundle](https://developer.android.com/reference/android/os/BaseBundle)`


``


implements

`[Cloneable](https://developer.android.com/reference/java/lang/Cloneable)`,

`[Parcelable](https://developer.android.com/reference/android/os/Parcelable)`


`

|---|---|------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [android.os.BaseBundle](https://developer.android.com/reference/android/os/BaseBundle) ||
|   | ↳ | android.os.PersistableBundle |

<br />

*** ** * ** ***

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](https://developer.android.com/reference/android/os/PersistableBundle)is a lazy container and as such it does NOT implement[Object.equals(java.lang.Object)](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))or[Object.hashCode()](https://developer.android.com/reference/java/lang/Object#hashCode()).  
**See also:**

- [Bundle](https://developer.android.com/reference/android/os/Bundle)

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ### Inherited constants                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From interface[android.os.Parcelable](https://developer.android.com/reference/android/os/Parcelable) |-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `int` | [CONTENTS_FILE_DESCRIPTOR](https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR) Descriptor bit used with[describeContents()](https://developer.android.com/reference/android/os/Parcelable#describeContents()): indicates that the Parcelable object's flattened representation includes a file descriptor.                                                                                                                                            | | `int` | [PARCELABLE_WRITE_RETURN_VALUE](https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE) Flag for use with[writeToParcel(Parcel, int)](https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)): the object being written is a return value, that is the result of a function such as "`Parcelable someFunction()`", "`void someFunction(out Parcelable)`", or "`void someFunction(inout Parcelable)`". | |

|                                                                                                                                                                                                          ### Fields                                                                                                                                                                                                           ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` public static final `[Creator](https://developer.android.com/reference/android/os/Parcelable.Creator)`<`[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle)`>` | [CREATOR](https://developer.android.com/reference/android/os/PersistableBundle#CREATOR) <br />                                                                                                                        |
| ` public static final `[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle)                                                                                       | [EMPTY](https://developer.android.com/reference/android/os/PersistableBundle#EMPTY) An unmodifiable`PersistableBundle`that is always[empty](https://developer.android.com/reference/android/os/BaseBundle#isEmpty()). |

|                                                                                                                                                               ### Public constructors                                                                                                                                                                ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle#PersistableBundle())`() ` Constructs a new, empty PersistableBundle.                                                                                                                                                                                  |
| ` `[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle#PersistableBundle(android.os.PersistableBundle))`(`[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle)` b) ` Constructs a PersistableBundle containing a copy of the mappings from the given PersistableBundle. |
| ` `[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle#PersistableBundle(int))`(int capacity) ` Constructs a new, empty PersistableBundle sized to hold the given number of elements.                                                                                                                        |

|                                                                                                                                                                                                                                                                               ### Public methods                                                                                                                                                                                                                                                                               ||
|-----------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[Object](https://developer.android.com/reference/java/lang/Object)                               | ` `[clone](https://developer.android.com/reference/android/os/PersistableBundle#clone())`() ` Clones the current PersistableBundle.                                                                                                                                                                                                                                                                                                                                       |
| ` `[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle)        | ` `[deepCopy](https://developer.android.com/reference/android/os/PersistableBundle#deepCopy())`() ` Make a deep copy of the given bundle.                                                                                                                                                                                                                                                                                                                                 |
| ` int`                                                                                              | ` `[describeContents](https://developer.android.com/reference/android/os/PersistableBundle#describeContents())`() ` Report the nature of this Parcelable's contents                                                                                                                                                                                                                                                                                                       |
| ` `[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle)        | ` `[getPersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle#getPersistableBundle(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/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](https://developer.android.com/reference/android/os/PersistableBundle#putPersistableBundle(java.lang.String,%20android.os.PersistableBundle))`(`[String](https://developer.android.com/reference/java/lang/String)` key, `[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle)` value) ` Inserts a PersistableBundle value into the mapping of this Bundle, replacing any existing value for the given key. |
| ` static `[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle) | ` `[readFromStream](https://developer.android.com/reference/android/os/PersistableBundle#readFromStream(java.io.InputStream))`(`[InputStream](https://developer.android.com/reference/java/io/InputStream)` inputStream) ` Reads a[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle)from an[InputStream](https://developer.android.com/reference/java/io/InputStream).                                                             |
| ` `[String](https://developer.android.com/reference/java/lang/String)                               | ` `[toString](https://developer.android.com/reference/android/os/PersistableBundle#toString())`() ` Returns a string representation of the[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle)that may be suitable for debugging.                                                                                                                                                                                                    |
| ` void`                                                                                             | ` `[writeToParcel](https://developer.android.com/reference/android/os/PersistableBundle#writeToParcel(android.os.Parcel,%20int))`(`[Parcel](https://developer.android.com/reference/android/os/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](https://developer.android.com/reference/android/os/PersistableBundle#writeToStream(java.io.OutputStream))`(`[OutputStream](https://developer.android.com/reference/java/io/OutputStream)` outputStream) ` Writes the content of the[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle)to a[OutputStream](https://developer.android.com/reference/java/io/OutputStream).                                          |

| ### Inherited methods |
|-----------------------|---|
| From class` `[android.os.BaseBundle](https://developer.android.com/reference/android/os/BaseBundle)` ` |-----------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` void`                                                                                                                                 | ` `[clear](https://developer.android.com/reference/android/os/BaseBundle#clear())`() ` Removes all elements from the mapping of this Bundle.                                                                                                                                                                                                                                                                                                                                              | | ` boolean`                                                                                                                              | ` `[containsKey](https://developer.android.com/reference/android/os/BaseBundle#containsKey(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key) ` Returns true if the given key is contained in the mapping of this Bundle.                                                                                                                                                                                                                      | | ` `[Object](https://developer.android.com/reference/java/lang/Object)                                                                   | ` `[get](https://developer.android.com/reference/android/os/BaseBundle#get(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key) ` *This method was deprecated in API level 33. Use the type-safe specific APIs depending on the type of the item to be retrieved, eg.[getString(java.lang.String)](https://developer.android.com/reference/android/os/BaseBundle#getString(java.lang.String)).*                                                  | | ` boolean`                                                                                                                              | ` `[getBoolean](https://developer.android.com/reference/android/os/BaseBundle#getBoolean(java.lang.String,%20boolean))`(`[String](https://developer.android.com/reference/java/lang/String)` key, boolean defaultValue) ` Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.                                                                                                                                    | | ` boolean`                                                                                                                              | ` `[getBoolean](https://developer.android.com/reference/android/os/BaseBundle#getBoolean(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key) ` Returns the value associated with the given key, or false if no mapping of the desired type exists for the given key.                                                                                                                                                                            | | ` boolean[]`                                                                                                                            | ` `[getBooleanArray](https://developer.android.com/reference/android/os/BaseBundle#getBooleanArray(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/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.                                                                                                             | | ` double`                                                                                                                               | ` `[getDouble](https://developer.android.com/reference/android/os/BaseBundle#getDouble(java.lang.String,%20double))`(`[String](https://developer.android.com/reference/java/lang/String)` key, double defaultValue) ` Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.                                                                                                                                        | | ` double`                                                                                                                               | ` `[getDouble](https://developer.android.com/reference/android/os/BaseBundle#getDouble(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key) ` Returns the value associated with the given key, or 0.0 if no mapping of the desired type exists for the given key.                                                                                                                                                                                | | ` double[]`                                                                                                                             | ` `[getDoubleArray](https://developer.android.com/reference/android/os/BaseBundle#getDoubleArray(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/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.                                                                                                               | | ` int`                                                                                                                                  | ` `[getInt](https://developer.android.com/reference/android/os/BaseBundle#getInt(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key) ` Returns the value associated with the given key, or 0 if no mapping of the desired type exists for the given key.                                                                                                                                                                                        | | ` int`                                                                                                                                  | ` `[getInt](https://developer.android.com/reference/android/os/BaseBundle#getInt(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` key, int defaultValue) ` Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.                                                                                                                                                    | | ` int[]`                                                                                                                                | ` `[getIntArray](https://developer.android.com/reference/android/os/BaseBundle#getIntArray(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/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.                                                                                                                     | | ` long`                                                                                                                                 | ` `[getLong](https://developer.android.com/reference/android/os/BaseBundle#getLong(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key) ` Returns the value associated with the given key, or 0L if no mapping of the desired type exists for the given key.                                                                                                                                                                                     | | ` long`                                                                                                                                 | ` `[getLong](https://developer.android.com/reference/android/os/BaseBundle#getLong(java.lang.String,%20long))`(`[String](https://developer.android.com/reference/java/lang/String)` key, long defaultValue) ` Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.                                                                                                                                                | | ` long[]`                                                                                                                               | ` `[getLongArray](https://developer.android.com/reference/android/os/BaseBundle#getLongArray(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/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.                                                                                                                   | | ` `[String](https://developer.android.com/reference/java/lang/String)                                                                   | ` `[getString](https://developer.android.com/reference/android/os/BaseBundle#getString(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/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.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)                                                                   | ` `[getString](https://developer.android.com/reference/android/os/BaseBundle#getString(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key, `[String](https://developer.android.com/reference/java/lang/String)` defaultValue) ` Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key or if a null value is explicitly associated with the given key. | | ` `[String[]](https://developer.android.com/reference/java/lang/String)                                                                 | ` `[getStringArray](https://developer.android.com/reference/android/os/BaseBundle#getStringArray(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/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.                                                                                                               | | ` boolean`                                                                                                                              | ` `[isEmpty](https://developer.android.com/reference/android/os/BaseBundle#isEmpty())`() ` Returns true if the mapping of this Bundle is empty, false otherwise.                                                                                                                                                                                                                                                                                                                          | | ` `[Set](https://developer.android.com/reference/java/util/Set)`<`[String](https://developer.android.com/reference/java/lang/String)`>` | ` `[keySet](https://developer.android.com/reference/android/os/BaseBundle#keySet())`() ` Returns a Set containing the Strings used as keys in this Bundle.                                                                                                                                                                                                                                                                                                                                | | ` void`                                                                                                                                 | ` `[putAll](https://developer.android.com/reference/android/os/BaseBundle#putAll(android.os.PersistableBundle))`(`[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle)` bundle) ` Inserts all mappings from the given PersistableBundle into this BaseBundle.                                                                                                                                                                                        | | ` void`                                                                                                                                 | ` `[putBoolean](https://developer.android.com/reference/android/os/BaseBundle#putBoolean(java.lang.String,%20boolean))`(`[String](https://developer.android.com/reference/java/lang/String)` key, boolean value) ` Inserts a Boolean value into the mapping of this Bundle, replacing any existing value for the given key.                                                                                                                                                               | | ` void`                                                                                                                                 | ` `[putBooleanArray](https://developer.android.com/reference/android/os/BaseBundle#putBooleanArray(java.lang.String,%20boolean[]))`(`[String](https://developer.android.com/reference/java/lang/String)` key, boolean[] value) ` Inserts a boolean array value into the mapping of this Bundle, replacing any existing value for the given key.                                                                                                                                           | | ` void`                                                                                                                                 | ` `[putDouble](https://developer.android.com/reference/android/os/BaseBundle#putDouble(java.lang.String,%20double))`(`[String](https://developer.android.com/reference/java/lang/String)` key, double value) ` Inserts a double value into the mapping of this Bundle, replacing any existing value for the given key.                                                                                                                                                                    | | ` void`                                                                                                                                 | ` `[putDoubleArray](https://developer.android.com/reference/android/os/BaseBundle#putDoubleArray(java.lang.String,%20double[]))`(`[String](https://developer.android.com/reference/java/lang/String)` key, double[] value) ` Inserts a double array value into the mapping of this Bundle, replacing any existing value for the given key.                                                                                                                                                | | ` void`                                                                                                                                 | ` `[putInt](https://developer.android.com/reference/android/os/BaseBundle#putInt(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` key, int value) ` Inserts an int value into the mapping of this Bundle, replacing any existing value for the given key.                                                                                                                                                                                  | | ` void`                                                                                                                                 | ` `[putIntArray](https://developer.android.com/reference/android/os/BaseBundle#putIntArray(java.lang.String,%20int[]))`(`[String](https://developer.android.com/reference/java/lang/String)` key, int[] value) ` Inserts an int array value into the mapping of this Bundle, replacing any existing value for the given key.                                                                                                                                                              | | ` void`                                                                                                                                 | ` `[putLong](https://developer.android.com/reference/android/os/BaseBundle#putLong(java.lang.String,%20long))`(`[String](https://developer.android.com/reference/java/lang/String)` key, long value) ` Inserts a long value into the mapping of this Bundle, replacing any existing value for the given key.                                                                                                                                                                              | | ` void`                                                                                                                                 | ` `[putLongArray](https://developer.android.com/reference/android/os/BaseBundle#putLongArray(java.lang.String,%20long[]))`(`[String](https://developer.android.com/reference/java/lang/String)` key, long[] value) ` Inserts a long array value into the mapping of this Bundle, replacing any existing value for the given key.                                                                                                                                                          | | ` void`                                                                                                                                 | ` `[putString](https://developer.android.com/reference/android/os/BaseBundle#putString(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key, `[String](https://developer.android.com/reference/java/lang/String)` value) ` Inserts a String value into the mapping of this Bundle, replacing any existing value for the given key.                                                                                            | | ` void`                                                                                                                                 | ` `[putStringArray](https://developer.android.com/reference/android/os/BaseBundle#putStringArray(java.lang.String,%20java.lang.String[]))`(`[String](https://developer.android.com/reference/java/lang/String)` key, `[String[]](https://developer.android.com/reference/java/lang/String)` value) ` Inserts a String array value into the mapping of this Bundle, replacing any existing value for the given key.                                                                        | | ` void`                                                                                                                                 | ` `[remove](https://developer.android.com/reference/android/os/BaseBundle#remove(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key) ` Removes any entry with the given key from the mapping of this Bundle.                                                                                                                                                                                                                                    | | ` int`                                                                                                                                  | ` `[size](https://developer.android.com/reference/android/os/BaseBundle#size())`() ` Returns the number of mappings contained in this Bundle.                                                                                                                                                                                                                                                                                                                                             | ||
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||
| From interface` `[android.os.Parcelable](https://developer.android.com/reference/android/os/Parcelable)` ` |------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract int`  | ` `[describeContents](https://developer.android.com/reference/android/os/Parcelable#describeContents())`() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.                                    | | ` abstract void` | ` `[writeToParcel](https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int))`(`[Parcel](https://developer.android.com/reference/android/os/Parcel)` dest, int flags) ` Flatten this object in to a Parcel. | ||

## Fields

### CREATOR

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final Creator<PersistableBundle> CREATOR
```

<br />

<br />

### EMPTY

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final PersistableBundle EMPTY
```

An unmodifiable`PersistableBundle`that is always[empty](https://developer.android.com/reference/android/os/BaseBundle#isEmpty()).

<br />

## Public constructors

### PersistableBundle

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public PersistableBundle ()
```

Constructs a new, empty PersistableBundle.

<br />

### PersistableBundle

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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()](https://developer.android.com/reference/android/os/PersistableBundle#deepCopy())if that is not what you want.

<br />

|                             Parameters                             ||
|-----|---------------------------------------------------------------|
| `b` | `PersistableBundle`: a PersistableBundle to be copied. <br /> |

**See also:**

- [deepCopy()](https://developer.android.com/reference/android/os/PersistableBundle#deepCopy())  

### PersistableBundle

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public PersistableBundle (int capacity)
```

Constructs a new, empty PersistableBundle sized to hold the given number of elements. The PersistableBundle will grow as needed.

<br />

|                               Parameters                                ||
|------------|-------------------------------------------------------------|
| `capacity` | `int`: the initial capacity of the PersistableBundle <br /> |

## Public methods

### clone

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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.

<br />

|                                               Returns                                                ||
|--------------------------------------------------------------------|----------------------------------|
| [Object](https://developer.android.com/reference/java/lang/Object) | a clone of this instance. <br /> |

### deepCopy

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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](https://developer.android.com/reference/android/os/Bundle),[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle),[ArrayList](https://developer.android.com/reference/java/util/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.

<br />

|                                              Returns                                              ||
|-------------------------------------------------------------------------------------------|--------|
| [PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle) | <br /> |

### describeContents

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int describeContents ()
```

Report the nature of this Parcelable's contents

<br />

|                                                                                                                         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](https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR) <br /> |

### getPersistableBundle

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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.

<br />

|                Parameters                 ||
|-------|------------------------------------|
| `key` | `String`: a String, or null <br /> |

|                                                          Returns                                                          ||
|-------------------------------------------------------------------------------------------|--------------------------------|
| [PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle) | a Bundle value, or null <br /> |

### putPersistableBundle

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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.

<br />

|                          Parameters                           ||
|---------|------------------------------------------------------|
| `key`   | `String`: a String, or null <br />                   |
| `value` | `PersistableBundle`: a Bundle object, or null <br /> |

### readFromStream

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static PersistableBundle readFromStream (InputStream inputStream)
```

Reads a[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle)from an[InputStream](https://developer.android.com/reference/java/io/InputStream).

The stream must be generated by[writeToStream(OutputStream)](https://developer.android.com/reference/android/os/PersistableBundle#writeToStream(java.io.OutputStream)).

<br />

|                            Parameters                            ||
|---------------|---------------------------------------------------|
| `inputStream` | `InputStream`: This value cannot be`null`. <br /> |

|                                                            Returns                                                            ||
|-------------------------------------------------------------------------------------------|------------------------------------|
| [PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle) | This value cannot be`null`. <br /> |

|                                    Throws                                     ||
|----------------------------------------------------------------------------|---|
| [IOException](https://developer.android.com/reference/java/io/IOException) |   |

**See also:**

- [writeToStream(OutputStream)](https://developer.android.com/reference/android/os/PersistableBundle#writeToStream(java.io.OutputStream))  

### toString

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String toString ()
```

Returns a string representation of the[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle)that may be suitable for debugging. It won't print the internal map if its content hasn't been unparcelled.

<br />

|                                                      Returns                                                      ||
|--------------------------------------------------------------------|-----------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | a string representation of the object. <br /> |

### writeToParcel

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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.

<br />

|                                                                                                                                                                                                                                Parameters                                                                                                                                                                                                                                ||
|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `parcel` | `Parcel`: The parcel to copy this bundle to. <br />                                                                                                                                                                                                                                                                                                                                                                                                            |
| `flags`  | `int`: Additional flags about how the object should be written. May be 0 or[Parcelable.PARCELABLE_WRITE_RETURN_VALUE](https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE). Value is either`0`or a combination of[Parcelable.PARCELABLE_WRITE_RETURN_VALUE](https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE), and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES <br /> |

### writeToStream

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void writeToStream (OutputStream outputStream)
```

Writes the content of the[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle)to a[OutputStream](https://developer.android.com/reference/java/io/OutputStream).

The content can be read by a[readFromStream(InputStream)](https://developer.android.com/reference/android/os/PersistableBundle#readFromStream(java.io.InputStream)).

<br />

|                             Parameters                             ||
|----------------|----------------------------------------------------|
| `outputStream` | `OutputStream`: This value cannot be`null`. <br /> |

|                                    Throws                                     ||
|----------------------------------------------------------------------------|---|
| [IOException](https://developer.android.com/reference/java/io/IOException) |   |

**See also:**

- [readFromStream(InputStream)](https://developer.android.com/reference/android/os/PersistableBundle#readFromStream(java.io.InputStream))