Skip to content

Instantly share code, notes, and snippets.

@anitaa1990
Created May 16, 2018 13:09
Show Gist options
  • Save anitaa1990/2431b602790003c128aa7dd49f74451e to your computer and use it in GitHub Desktop.
Save anitaa1990/2431b602790003c128aa7dd49f74451e to your computer and use it in GitHub Desktop.
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