Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/android/adservices/ondevicepersonalization/MutableKeyValueStore#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/adservices/ondevicepersonalization/MutableKeyValueStore#inhmethods)

# MutableKeyValueStore

*** ** * ** ***

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


`
public


interface
MutableKeyValueStore
`


`


implements

https://developer.android.com/reference/android/adservices/ondevicepersonalization/KeyValueStore


`

|---|
| android.adservices.ondevicepersonalization.MutableKeyValueStore |

<br />

*** ** * ** ***

An interface to a read-write key-value store.

Used as a Data Access Object for the LOCAL_DATA table.
**See also:**

- `https://developer.android.com/reference/android/adservices/ondevicepersonalization/IsolatedService#getLocalData(android.adservices.ondevicepersonalization.RequestToken)`

## Summary

| ### Public methods ||
|---|---|
| ` abstract byte[]` | ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/MutableKeyValueStore#put(java.lang.String,%20byte[])(https://developer.android.com/reference/java/lang/String key, byte[] value) ` Associates the specified value with the specified key. |
| ` abstract byte[]` | ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/MutableKeyValueStore#remove(java.lang.String)(https://developer.android.com/reference/java/lang/String key) ` Removes the mapping for the specified key. |

| ### Inherited methods |
|---|---|
| From interface ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/KeyValueStore ` |---|---| | ` abstract byte[]` | ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/KeyValueStore#get(java.lang.String)(https://developer.android.com/reference/java/lang/String key) ` Looks up a key in a read-only store. | | ` abstract https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/java/lang/String>` | ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/KeyValueStore#keySet()() ` Returns a Set view of the keys contained in the REMOTE_DATA table. | ||

## Public methods

### put

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

```
public abstract byte[] put (String key, 
                byte[] value)
```

Associates the specified value with the specified key.
If a value already exists for that key, the old value is replaced.


This method may take several seconds to complete, so it should
only be called from a worker thread.

<br />

| Parameters ||
|---|---|
| `key` | `String`: key with which the specified value is to be associated. This value cannot be `null`. <br /> |
| `value` | `byte`: value to be associated with the specified key. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `byte[]` | the previous value associated with key, or null if there was no mapping for key. <br /> |

### remove

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

```
public abstract byte[] remove (String key)
```

Removes the mapping for the specified key.


This method may take several seconds to complete, so it should
only be called from a worker thread.

<br />

| Parameters ||
|---|---|
| `key` | `String`: key whose mapping is to be removed. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `byte[]` | the previous value associated with key, or null if there was no mapping for key. <br /> |