Created
May 16, 2018 13:09
-
-
Save anitaa1990/2431b602790003c128aa7dd49f74451e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SingletonSampleClass { | |
private Context context; | |
private static SingletonSampleClass instance; | |
private SingletonSampleClass(Context context) { | |
this.context = context; | |
} | |
public synchronized static SingletonSampleClass getInstance(Context context) { | |
if (instance == null) instance = new SingletonSampleClass(context); | |
return instance; | |
} | |
public void onDestroy() { | |
if(context != null) { | |
context = null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment