From my point of view, SharedPreference
acts like local storage on your phone. It works well if you want to save some state like true or false, as simple as possible. Why? Because saving and get the data from SharedPreference
quite painful.
Example use of SharedPreference
. If you want to show a banner to the user, in a condition that the user never closes it before. So, if the user closes it before, it won't be shown to the user. You can save that state whether the user had close it before or not in SharedPreference
. That's my perspective of using SharedPreference
Now, for onActivityResult
. I usually use it if I want to get a variable that, usually, had modified in other activities. And that variable is important, for example, to keep update to the user about the data he/she been modified before.
Example use of onActivityResult
. Let's say you move from activity A to activity B, which carried some value with it. In an activity B, the value is being modified. And when the user back to activity A, from activity B, it's being carried too. That value is now used in activity A to show important info, which links to what user doing in activity B
Hope this answer helps you. Sorry for my bad grammar. Peace