使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
MutableKeyValueStore
public
interface
MutableKeyValueStore
implements
KeyValueStore
android.adservices.ondevicepersonalization.MutableKeyValueStore
|
指向读写键值对存储区的接口。
用作 LOCAL_DATA 表的数据访问对象。
摘要
公共方法 |
abstract
byte[]
|
put(String key, byte[] value)
将指定值与指定键相关联。
|
abstract
byte[]
|
remove(String key)
移除指定键的映射。
|
公共方法
put
public abstract byte[] put (String key,
byte[] value)
将指定值与指定键相关联。
如果该键的值已存在,系统会替换旧值。
此方法可能需要几秒钟才能完成,因此仅应从工作器线程调用。
参数 |
key |
String :要与指定值关联的键。此值不能为 null 。 |
value |
byte :要与指定键关联的值。此值不能为 null 。 |
返回 |
byte[] |
与键相关联的先前值,如果没有键的映射,则返回 null。 |
remove
public abstract byte[] remove (String key)
移除指定键的映射。
此方法可能需要几秒钟才能完成,因此仅应从工作器线程调用。
参数 |
key |
String :要移除的映射的键。此值不能为 null 。 |
返回 |
byte[] |
与键相关联的先前值,如果没有键的映射,则返回 null。 |
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# MutableKeyValueStore\n\n[**Added in Android UpsideDownCakePrivacySandbox**](/preview) \nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nMutableKeyValueStore\n====================\n\n\n`\npublic\n\n\ninterface\nMutableKeyValueStore\n`\n\n\n`\n\n\nimplements\n\n`[KeyValueStore](/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/KeyValueStore)`\n\n\n`\n\n|-----------------------------------------------------------------|\n| android.adservices.ondevicepersonalization.MutableKeyValueStore |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nAn interface to a read-write key-value store.\n\nUsed as a Data Access Object for the LOCAL_DATA table. \n**See also:**\n\n- [IsolatedService.getLocalData(RequestToken)](/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/IsolatedService#getLocalData(android.adservices.ondevicepersonalization.RequestToken))\n\nSummary\n-------\n\n| ### Public methods ||\n|--------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract byte[]` | ` `[put](/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/MutableKeyValueStore#put(java.lang.String,%20byte[]))`(`[String](/reference/java/lang/String)` key, byte[] value) ` Associates the specified value with the specified key. |\n| ` abstract byte[]` | ` `[remove](/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/MutableKeyValueStore#remove(java.lang.String))`(`[String](/reference/java/lang/String)` key) ` Removes the mapping for the specified key. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From interface ` `[android.adservices.ondevicepersonalization.KeyValueStore](/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/KeyValueStore)` ` |----------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract byte[]` | ` `[get](/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/KeyValueStore#get(java.lang.String))`(`[String](/reference/java/lang/String)` key) ` Looks up a key in a read-only store. | | ` abstract `[Set](/reference/java/util/Set)`\u003c`[String](/reference/java/lang/String)`\u003e` | ` `[keySet](/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/KeyValueStore#keySet())`() ` Returns a Set view of the keys contained in the REMOTE_DATA table. | ||\n\nPublic methods\n--------------\n\n### put\n\n[**Added in Android UpsideDownCakePrivacySandbox**](/preview) \n\n```\npublic abstract byte[] put (String key, \n byte[] value)\n```\n\nAssociates the specified value with the specified key.\nIf a value already exists for that key, the old value is replaced.\n\n\u003cbr /\u003e\n\n\nThis method may take several seconds to complete, so it should\nonly be called from a worker thread.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------|------------------------------------------------------------------------------------------------------|\n| `key` | `String`: key with which the specified value is to be associated This value cannot be `null`. \u003cbr /\u003e |\n| `value` | `byte`: value to be associated with the specified key This value cannot be `null`. \u003cbr /\u003e |\n\n| Returns ||\n|----------|-----------------------------------------------------------------------------------------|\n| `byte[]` | the previous value associated with key, or null if there was no mapping for key. \u003cbr /\u003e |\n\n### remove\n\n[**Added in Android UpsideDownCakePrivacySandbox**](/preview) \n\n```\npublic abstract byte[] remove (String key)\n```\n\nRemoves the mapping for the specified key.\n\n\u003cbr /\u003e\n\n\nThis method may take several seconds to complete, so it should\nonly be called from a worker thread.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-------|----------------------------------------------------------------------------------|\n| `key` | `String`: key whose mapping is to be removed This value cannot be `null`. \u003cbr /\u003e |\n\n| Returns ||\n|----------|-----------------------------------------------------------------------------------------|\n| `byte[]` | the previous value associated with key, or null if there was no mapping for key. \u003cbr /\u003e |"]]