Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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