Answers for "What is a singleton class in Android?"

0

What is a singleton class in Android?

private static volatile RESTService instance;
 protected RESTService(Context context) {
     super(context);
 }
 
 public static RESTService getInstance(Context context) {
 if (instance == null) {
    synchronized (RESTService.class) {
       if (instance == null) instance = new RESTService(context);
         }
     }
     return instance;
 }
Posted by: Guest on June-02-2021

Browse Popular Code Answers by Language