How to use SharedPreferences to save more than one values?

前端 未结 6 1568
慢半拍i
慢半拍i 2020-11-29 08:03

I am developing a dictionary app. In my app, I assume that user wants to save favourite words. I have decided to use SharedPreferences to save these values

6条回答
  •  情深已故
    2020-11-29 08:21

    SharedPreferences work via simple key/value so when you provide a new value for the same key, the previous value is overwritten. The only way to do what you're trying to do is to use different keys, which sort of hints towards the fact that you probably shouldn't be using SharedPreferences for what you're trying to do.

提交回复
热议问题