There is a need to store user data on his mobile device! Data may be different, pictures, text files, etc. In fact, I need to reserve space on the memory card or internal storage of the device for a certain number of megabytes. Those. I need some application cache.

On the Internet, I often find out how to do such things using sharedpreferences but in my opinion, this is not exactly what I need!

The question is what are the mechanisms for reserving and managing memory on a mobile device.

  • And why not create a folder on the SD, name it %ИМЯ_ПРИЛОЖЕНИЯ% and not put all your files there? ... - YuriySPb
  • @Yuriy SPb I did just that) it was just interesting to me, maybe there are already some kind of ready-made memory management mechanisms on the device. - Kirill Stoianov

1 answer 1

SharedPreferences class is usually used to store small information, which, in turn, is stored directly in the application itself, in a key-value type. As a rule, store id, name, and so on. This class does not require any permission .

In your case, you most likely need to use SQLite (if data is updated regularly and should be stored) for text data, for storing links to files, and SD-card for storing the files themselves. This requires permission WRITE_EXTERNAL_STORAGE . But again, you need to know the full task to give specific advice.

  • If it’s specifically: the application is a chat, you need: storing contacts (name, phone number, address), saving correspondence (photos, text messages) as a whole is all. - Kirill Stoianov
  • Then use Sqlite to store text information and sd-card to store photos - Android Android