Skip to content

Instantly share code, notes, and snippets.

@GauravChaddha1996
Last active July 3, 2017 10:55
Show Gist options
  • Save GauravChaddha1996/048b175b3ca098030033894b1a210191 to your computer and use it in GitHub Desktop.
Save GauravChaddha1996/048b175b3ca098030033894b1a210191 to your computer and use it in GitHub Desktop.
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