map组织储存
Android recently released a couple crypto application program interfaces (APIs) as part of Android Jetpack which are EncryptedSharedPreferences and EncryptedFile. We’ll be focusing on EncryptedSharedPreferences and show how to build a generic abstraction on top that allows the developer to not only provide secure storage of arbitrary data, but also re-think the usage of preferences.
Android最近发布了几个加密应用程序接口(API)作为Android Jetpack的一部分,分别是EncryptedSharedPreferences和EncryptedFile 。 我们将专注于EncryptedSharedPreferences并展示如何在其上构建通用的抽象,该抽象使开发人员不仅可以提供任意数据的安全存储,还可以重新考虑首选项的用法。
储存资料 (Storing data)
There are a few different ways of storing data depending on the use case. Here are a few to mention:
根据使用情况,有几种不同的数据存储方式。 这里有几点要提:
共享首选项 (SharedPreferences)
SharedPreferences provides an abstraction over a flat file on disk that allows for writing key/value pairs to a clear text file in your app’s directory. Under normal situations this is perfectly secure as your app’s directory is protected by Android’s sandbox environment.
SharedPreferences提供了磁盘上平面文件的抽象,该抽象允许将键/值对写入应用程序目录中的明文文件。 在正常情况下,这是绝对安全的,因为您应用的目录受Android沙箱环境的保护。
SQLite的 (SQLite)
For large volumes of data that need to be queried often, or used as part of UI rendering, the developer will likely be using a SQLite database. The recommended abstraction over SQLite is to use Room rather than SQLite directly but it’s still SQLite behind the scenes.
对于需要经常查询或用作UI渲染一部分的大量数据,开发人员可能会使用SQLite数据库。 推荐的对SQLite的抽象是直接使用