Answer the question
In order to leave comments, you need to log in
How is a singleton different from a one-time object definition?
Why is the first block worse than the second? You can also write the first and second block of code once in onCreate() , and then use the database. Or does it mean that when using the second block of code in another Activity , the same instance will be used, and when using the first, a new instance will be created?
Answer the question
In order to leave comments, you need to log in
The answer is written in the question - this is a heavy operation, so they recommend doing it once. A static application instance is not very cool, singletons themselves are generally an anti-pattern, you should not do this.
Better take and learn the basics of Dagger 2, it will immediately become better.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question