存储界面
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
保留游戏和保存数据的方法。
方法
clear()
移除所有键值对(如有)。
getItem(key)
返回与给定键关联的当前值;如果给定键不存在,则返回 null。
removeItem(key)
如果存在带有给定键的键值对,则移除该键值对。
setItem(key, value)
将通过键来标识的键值对的值设为指定值;如果之前不存在任何键,则创建一个新的键值对。
要求
- 当用户取得实质性进展(例如通过一个关卡)时,游戏必须使用该界面来保存进度。
- 游戏启动时,必须恢复已保存的进度。
- 游戏必须能够从之前版本的游戏中恢复已保存的进度。
- 已保存的游戏的总大小必须小于 3 MiB,最好小于 500 KiB。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-12-24。
[[["易于理解","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):2024-12-24。"],[[["Games must utilize the provided interface (`clear()`, `getItem()`, `removeItem()`, `setItem()`) for saving player progress, especially upon significant events like completing a level."],["Games are required to automatically load and apply any saved progress when launched, ensuring continuity for the player."],["Saved game data must be compatible with prior game versions, allowing players to seamlessly continue progress from older builds."],["All saved game data for a user should not exceed 3 MiB in total size, and ideally be kept under 500 KiB to optimize storage space and loading times."]]],[]]