I sorted out a topic for myself: how to recover data after folding. I Bundle (SavedInstanceState) that you need to use Bundle (SavedInstanceState) or SharedPreferences .

Now I'm wondering which one to use in which cases? What is the difference between them? Which is preferable for what?

Thank you, thank you!

  • the difference between them is that they are two completely different mechanisms for solving completely different tasks - they are not alternative solutions and are given preference based on the problem being solved. Comparing them for coincidences \ differences is absolutely ridiculous, how to compare the differences between a steamer and a notebook in the box - pavlofff
  • Well, thank you, this is your opinion, it was possible to give an example why it is not worth it, well, you prefer a place to satire, and thank you for that. But all the same, the question is relevant for me. Thank you for your responsiveness - elik

1 answer 1

Bundle and SharedPreferences are two different things.

Objects of the Bundle class are mainly used to save the state of an object during the life cycle of a component of an android application (for example, an activation or a fragment).

SharedPreferences used to save any ключ:значение pairs for their long-term storage . The main purpose of SharedPreferences is to save application settings.

  • AAAAAA ponel ponel !!!! thank! - elik
  • In general, the Bundle itself is just a kind of universal container for grouping different types of data in one object, the fact that it is used to save the state, is only one of its applications - it is used in the API wherever several parameters of unknown type are required to be transferred - pavlofff