Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
MutableKeyValueStore
public
interface
MutableKeyValueStore
implements
KeyValueStore
android.adservices.ondevicepersonalization.MutableKeyValueStore
|
Một giao diện đến kho lưu trữ khoá-giá trị đọc-ghi.
Được dùng làm Đối tượng truy cập dữ liệu cho bảng LOCAL_DATA.
Tóm tắt
Phương thức công khai |
abstract
byte[]
|
put(String key, byte[] value)
Liên kết giá trị đã chỉ định với khoá đã chỉ định.
|
abstract
byte[]
|
remove(String key)
Xoá lượt ánh xạ cho khoá đã chỉ định.
|
Phương thức công khai
put
public abstract byte[] put (String key,
byte[] value)
Liên kết giá trị đã chỉ định với khoá đã chỉ định.
Nếu đã tồn tại một giá trị cho khoá đó, thì giá trị cũ sẽ được thay thế.
Phương thức này có thể mất vài giây để hoàn tất, vì vậy, bạn chỉ nên gọi phương thức này từ một luồng worker.
Tham số |
key |
String : khoá liên kết với giá trị được chỉ định.
Giá trị này không được là null . |
value |
byte : giá trị liên kết với khoá đã chỉ định.
Giá trị này không được là null . |
Giá trị trả về |
byte[] |
giá trị trước đó được liên kết với khoá hoặc giá trị rỗng nếu không có lượt ánh xạ cho khoá. |
remove
public abstract byte[] remove (String key)
Xoá lượt ánh xạ cho khoá đã chỉ định.
Phương thức này có thể mất vài giây để hoàn tất, vì vậy, bạn chỉ nên gọi phương thức này từ một luồng worker.
Tham số |
key |
String : khoá có lượt ánh xạ cần xoá.
Giá trị này không được là null . |
Giá trị trả về |
byte[] |
giá trị trước đó được liên kết với khoá hoặc giá trị rỗng nếu không có lượt ánh xạ cho khoá. |
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],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 |"]]