Last active
July 3, 2017 10:55
-
-
Save GauravChaddha1996/048b175b3ca098030033894b1a210191 to your computer and use it in GitHub Desktop.
This file contains 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 DataManager { | |
private static DataManager dataManager; | |
private final Context context; | |
private SharedPreferencesHelper sharedPreferencesHelper; | |
private DataManager(Context context) { | |
this.context = context; | |
/* Create your delegation managers here like | |
NetworkManager, SharedPreferencesHelper etc. */ | |
sharedPreferencesHelper = new SharedPreferencesHelper(); | |
} | |
public static void init(Context context) { | |
dataManager = new DataManager(context); | |
} | |
public static DataManager getDataManager(){ | |
return dataManager; | |
} | |
/** | |
* Change the name in the appropriate model. It can be | |
shared preferences, or SQL db or Realm db or making a | |
network call (Dispatched via Network Manager) to save the | |
name in server. Here I'm using a shared preference as an | |
example */ | |
public void saveName(String name) { | |
sharedPreferencesHelper.saveName(context, name); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment