透過集合功能整理內容
你可以依據偏好儲存及分類內容。
KeyValueStore
public
interface
KeyValueStore
android.adservices.ondevicepersonalization.KeyValueStore
|
唯讀鍵/值儲存庫的存取介面。可用做 REMOTE_DATA 資料表的資料存取物件。
摘要
公用方法
get
public abstract byte[] get (String key)
在唯讀儲存庫中查詢鍵。
此方法可能需要幾秒鐘才能完成,因此應僅從背景工作執行緒呼叫。
參數 |
key |
String :要查詢的鍵。此值不能為 null 。 |
傳回 |
byte[] |
指定鍵對應的值;如果該鍵沒有對應關係,則傳回空值。 |
KeySet
public abstract Set<String> keySet ()
傳回 REMOTE_DATA 資料表所含鍵的 Set 檢視畫面。
此方法可能需要幾秒鐘才能完成,因此應僅從背景工作執行緒呼叫。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。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,["# KeyValueStore\n\n[**Added in Android UpsideDownCakePrivacySandbox**](/preview) \nSummary: [Methods](#pubmethods) \n\nKeyValueStore\n=============\n\n\n`\npublic\n\n\ninterface\nKeyValueStore\n`\n\n\n`\n\n\n`\n\n|----------------------------------------------------------|\n| android.adservices.ondevicepersonalization.KeyValueStore |\n\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known indirect subclasses [MutableKeyValueStore](/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/MutableKeyValueStore) |------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------| | [MutableKeyValueStore](/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/MutableKeyValueStore) | An interface to a read-write key-value store. | |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nAn interface to a read-only key-value store.\n\nUsed as a Data Access Object for the REMOTE_DATA table. \n**See also:**\n\n- [IsolatedService.getRemoteData(RequestToken)](/design-for-safety/privacy-sandbox/reference/adservices/ondevicepersonalization/IsolatedService#getRemoteData(android.adservices.ondevicepersonalization.RequestToken))\n\nSummary\n-------\n\n| ### Public methods ||\n|----------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` 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. |\n| ` 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### get\n\n[**Added in Android UpsideDownCakePrivacySandbox**](/preview) \n\n```\npublic abstract byte[] get (String key)\n```\n\nLooks up a key in a read-only store.\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`: The key to look up. This value cannot be `null`. \u003cbr /\u003e |\n\n| Returns ||\n|----------|----------------------------------------------------------------------------------------------------------|\n| `byte[]` | the value to which the specified key is mapped, or null if there contains no mapping for the key. \u003cbr /\u003e |\n\n### keySet\n\n[**Added in Android UpsideDownCakePrivacySandbox**](/preview) \n\n```\npublic abstract Set\u003cString\u003e keySet ()\n```\n\nReturns a Set view of the keys contained in the REMOTE_DATA table.\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| Returns ||\n|----------------------------------------------------------------------------|-------------------------------------|\n| [Set](/reference/java/util/Set)`\u003c`[String](/reference/java/lang/String)`\u003e` | This value cannot be `null`. \u003cbr /\u003e |"]]