Android SharedPreferences 导致存储空间变大

Android SharedPreferences causing storage to be big

我在我的应用程序中使用 SharedPreferences 在某些时候保存一些字符串值。 但问题是在 运行 应用几次后,用户 phone 上将有大约 100MB 的数据,并且这些数据越来越大。 当然,我正在用 sharedPreferences 上的旧数据替换新数据 我应该怎么办 ? 我应该改用数据库吗?

来自 Android 文档:https://developer.android.com/training/data-storage/shared-preferences

If you have a relatively small collection of key-values that you'd like to save, you should use the SharedPreferences APIs. A SharedPreferences object points to a file containing key-value pairs and provides simple methods to read and write them.

对小键值对使用共享首选项,例如存储用户 ID 或一些设置变量,基于这些变量可以进一步定义应用程序体验。

您的选择是 SQLite 或 Room (SQLite Wrapper) 数据库,如果预计数据会增长这么多(GB 或更多),请使用 Firebase 或私有服务器数据库的远程存储