Answer the question
In order to leave comments, you need to log in
How to store data that is needed everywhere and always on android?
Yes, we have many methods for storing information - from SharedPreferences to ExternalStorage.
Yes, we can drag data along with "intent.putExtra".
However, when using the first "yes", we will have to spend resources and time in each onCreate on constantly defining classes and information, and in the second, their definition is added to all this before creating an intent, as well as constant duplication (?) of this information (I’m not sure about the latter - I’m arguing purely logically, all previous activations and their data remain in the backStack).
This raises the question - how exactly should such data be stored?
Answer the question
In order to leave comments, you need to log in
A static container class, there can't be a faster and lighter option.
Calculate how many specific resources and time, most likely, will not be critical at all.
Singleton
Вы там посмотрите кучу реализаций, глянете что да как, лично я предпочитаю такую версию Singleton-а
class enum MySingleton{
INSTANCE;
// дальше данные
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question