阅读更多
package cn.madfinger.android.core;import java.lang.reflect.Method;import java.lang.reflect.ParameterizedType;import java.lang.reflect.Type;import java.util.ArrayList;import java.util.Arrays;import java.util.Date;import java.util.HashMap;import java.util.Iterator;import java.util.LinkedList;import java.util.List;import java.util.Map;import java.util.UUID;import org.json.JSONException;import org.json.JSONObject;import android.content.ContentValues;import android.database.Cursor;import android.util.Log;import cn.madfinger.android.core.util.DateUtils;import cn.madfinger.android.core.util.PageList;import cn.madfinger.android.core.util.StrUtils;import cn.madfinger.android.core.util.impl.PageListImpl;/** * 数据库操作基类 * * @author wiley * * @param */public abstract class AbstractBaseDao {protected static String TAG = AbstractBaseDao.class.getSimpleName();private static Map TYPES = new HashMap();public static final int TYPE_STRING=1;public static final int TYPE_INTEGER=2;public static final int TYPE_LONG=3;public static final int TYPE_SHORT=4;public static final int TYPE_FLOAT=5;public static final int TYPE_DOUBLE=6;static {TYPES.put("date", TYPE_STRING);TYPES.put("string", TYPE_STRING);TYPES.put("integer", TYPE_INTEGER);TYPES.put("int", TYPE_INTEGER);TYPES.put("long", TYPE_LONG);TYPES.put("short", TYPE_SHORT);TYPES.put("float", TYPE_FLOAT);TYPES.put("double", TYPE_DOUBLE);}//protected SQLiteDatabase dbHandler;protected SqliteHelper sqliteHelper;public AbstractBaseDao() {}public void setSqliteHelper(SqliteHelper sqliteHelper) {this.sqliteHelper = sqliteHelper;}public long getCount(){return getCount(null, null, null, null);}public long getCount(String selection, String[] selectionArgs){return getCount(selection, selectionArgs, null, null);}public long getCount(String selection, String[] selectionArgs,String groupBy, String having){String sqlString="SELECT COUNT(*) AS NUM FROM "+this.getEntityClass().getSimpleName();if(!StrUtils.isEmpty(selection)){sqlString+=" "+selection;}if(!StrUtils.isEmpty(groupBy)){sqlString+=" "+groupBy;if(!StrUtils.isEmpty(having)){sqlString+=having;}}Cursor cursor=this.execSql(sqlString,selectionArgs);cursor.moveToFirst();return cursor.getLong(0);}public PageList
- Android的NDK开发(3)————JNI数据类型的详解
- Android之断点续传下载
- android SQLite
- Android如何导入已有的外部数据库
- SQlite Android(安卓)数据库应用程序系统
- Android(安卓)boot process stub
- android SQLite的CRUD
- First project in android
- Android的VideoView如何循环播放
随机推荐
-
演示文本操作、演示样式属性操作 、演示
-
MVC-安装jQuery的npm和yarn的方法
-
flex 容器和项目 常用属性
-
微信JSSDK签名
-
JavaScript基础了解
-
07-12作业
-
第二十一课 Bootstrap学习
-
file本地文本传输协议为什么无法设置cook
-
学习笔记:表格小知识
-
匿名函数、箭头函数和立即执行函数