There is a game in which, for example, 20 different user game resources. The number of them constantly (every 1-5 seconds) varies.

Question: What is the best way to store them and how often to save them?

My assumptions:

  1. Every time to write resources in SharedPreference.
  2. Every time to write resources in SQLite.
  3. Store resources in some singleton and in onPause save them in SharedPreference / SQLite.

But on the first two points, it seems to me that the record will be slow in SharedPreference / SQLite. (?)

Who has experience in this - please share what is the best way to organize it?

  • one
    when writing / changing 20 values ​​every second, you will not notice changes in the program's work. You can use either this or that. It all depends on the context of future use. If the data does not participate in samples from the database and should not be collected, then it is more logical to use the SharedPreference. but if you need to keep some statistics, then SQLite to help) - Vitalii Obideiko
  • Measure the speed and tell - strangeqargo
  • one
    Olso, if you are going to port the game somewhere (and all of a sudden), then the sqlite is easier to port, probably, or are there any wrappers for sharedPreference? - strangeqargo

1 answer 1

Shared preference is still better to use only to save progress and settings, because in fact the shared preference is a simple xml, as the volume increases, the speed drops significantly, I recommend using SQLite.