It is necessary: to store data (level, the number of one parameter, the number of another parameter, and so the pieces are 20 different).

I think this: create a singleton class to which I will access via getInstance, the Game object will be stored in the class in a single copy with all the fields I need and throughout the game I will change these fields. When you exit the game - save.

How good is this approach?

( ps somewhere I once read that you should not use a singleton class like this, but I cannot find an article )

Closed due to the fact that it is necessary to reformulate the question so that it was possible to give an objectively correct answer by the participants Vladyslav Matviienko , Juriy Spb , aleksandr barakin , sercxjo , Dmitriy Simushev 29 Apr '16 at 9:44 .

The question gives rise to endless debates and discussions based not on knowledge, but on opinions. To get an answer, rephrase your question so that it can be given an unambiguously correct answer, or delete the question altogether. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    As for me - everything is correct. Only it is better to save not at the exit, but at each data change. You can simply serialize a class and write it to SharedPreferences - Vladyslav Matviienko
  • @metalurgus, oh, at the expense of serialization, it is a good idea not to write each value under a separate key) - researcher

0