Last active
August 29, 2015 13:57
-
-
Save FisherKK/9805946 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 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