Mess with the shared preferences of android - which function to use?

前端 未结 4 1897
旧时难觅i
旧时难觅i 2020-12-17 04:47

Here\'s a standard task: store some values in the application\'s shared preferences in order to be able to retrieve it later on. But one will discover that there are 3 funct

4条回答
  •  萌比男神i
    2020-12-17 05:13

    It depends. #1 Will return the SharedPreferences for whichever Context you pass it. #2 Will return the SharedPreferences for the context of the Activity you're in. This may be the same as #1 or it might not. #3 Will let you break your SharedPreferences up into different groups and name them. This might be a nice way to break things up but I have never actually done it.

提交回复
热议问题