透過集合功能整理內容
你可以依據偏好儲存及分類內容。
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[] |
與鍵相關聯的前一個值;如果鍵沒有對應關係,則傳回空值。 |
remove
public abstract byte[] remove (String key)
移除指定鍵的對應關係。
此方法可能需要幾秒鐘才能完成,因此應僅從背景工作執行緒呼叫。
參數 |
key |
String :要移除對應關係的鍵
此值不能為 null 。 |
傳回 |
byte[] |
與鍵相關聯的前一個值;如果鍵沒有對應關係,則傳回空值。 |
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間: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"]],["上次更新時間: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 |"]]