What does it mean?

Singleton is a software design pattern that you can get an instance of it at one time. Singletons are useful when a system needs a resource to control the action of the entire software system. It provides easy access from anywhere on the system.


You can say why we are not using static objects like in Java or global variables? Because Kotlin itself does not contain “static” keyword. Of course, you can use other identifiers that have similar functionality with static but this is a topic for another article. Also :

On the other hand, benefit of singletons against global variables :

Basic usage is like below:

After that, you can call with

Thank you for reading the article. Bye and stay safe!

Android Developer @Getir, who is eager to learn new things. Lover of science, sci-fi, gaming, nature, human psychology, and gaming.