Skip to content

Instantly share code, notes, and snippets.

@FisherKK
Last active August 29, 2015 13:57
Show Gist options
  • Save FisherKK/9805946 to your computer and use it in GitHub Desktop.
Save FisherKK/9805946 to your computer and use it in GitHub Desktop.
public class BoxRepository {
public static void insertOrUpdate(Context context, Box box) {
getBoxDao(context).insertOrReplace(box);
}
public static void clearBoxes(Context context) {
getBoxDao(context).deleteAll();
}
public static void deleteBoxWithId(Context context, long id) {
getBoxDao(context).delete(getBoxForId(context, id));
}
public static List<Box> getAllBoxes(Context context) {
return getBoxDao(context).loadAll();
}
public static Box getBoxForId(Context context, long id) {
return getBoxDao(context).load(id);
}
private static BoxDao getBoxDao(Context c) {
return ((DaoExampleApplication) c.getApplicationContext()).getDaoSession().getBoxDao();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment