【发布时间】:2019-04-17 18:27:39
【问题描述】:
我想在我的 Android 应用中使用SharedPreferences 保存并获取MutableList。
我试过了,但它不正确:
private fun saveFavorite(saveFavorite : MutableList<String>) {
val sharedPref = this.getPreferences(Context.MODE_PRIVATE) ?: return
with(sharedPref.edit()) {
putStringSet("lastFavorite",saveFavorite)
apply()
}
}
【问题讨论】:
-
您遇到的具体错误是什么?
-
该代码没有保存任何内容,这只是我想要存储可变列表的方式(代码)的示例
标签: android kotlin sharedpreferences