Back to project page android-mvc-framework.
The source code is released under:
Apache License
If you think the Android project android-mvc-framework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.android_mvc.sample_project.db.dao; /* ww w . j a va 2 s .c o m*/ import java.util.ArrayList; import com.android_mvc.sample_project.db.entity.Friend; import com.android_mvc.framework.db.DBHelper; import com.android_mvc.framework.db.dao.BaseDAO; import android.content.Context; /** * ??????????????????????? * @author id:language_and_engineering */ public class FriendDAO extends BaseDAO<Friend> { private DBHelper helper = null; public FriendDAO(Context context) { helper = new DBHelper(context); } // ------------ C -------------- /** * 1??????????????? */ public Friend create(String name, Integer age, Boolean favoriteFlag) { // ????????????? Friend f = new Friend(); f.setName(name); f.setAge( age ); f.setFavorite_flag( favoriteFlag ); // DB?? f.save(helper); return f; } // ------------ R -------------- /** * ??????????????????????????? */ public ArrayList<Friend> findAll() { return findAll(helper, Friend.class); } /** * ?????ID????????????????? */ public Friend findById(Long friend_id) { return findById( helper, Friend.class, friend_id ); } // NOTE: ?????????????????????????????????Finder?????????????? // findAll?findById??????????? // ------------ U -------------- /** * ?????????????????????????????????????? */ public Friend invertFavoriteFlag( Long friend_id ) { // id?????????? Friend f = findById( friend_id ); // ???????????? f.setFavorite_flag( ! f.getFavorite_flag() ); // DB?? f.save(helper); return f; } // ------------ D -------------- /** * ?????ID????????????? */ public void deleteById( Long friend_id ) { Friend f = findById(friend_id); // DB???????????? f.delete(helper); } }