阅读更多
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如何导入已有的外部数据库
- SQlite Android 数据库应用程序系统
- android 通知 手机 媒体 数据库 更新
- 获得android下面,所有的数据库
- android的数据库API操作
- Android对IO进行读写操作实例
- Android中SeekBar进度条操作
- android下获取无线wif信号、ssid、MAC等操作类
- 优雅的处理Android数据库升级的问题
随机推荐
-
Android:Changes to the SecretKeyFactory
-
Android(安卓)删除指定文件代码
-
我的Android计算器
-
巧妙均分TabLayout tab
-
Android(安卓)AApt错误
-
Android中的那些sql语句
-
android 菜单事件处理
-
Android(安卓)主界面 九宫格 超灵活的配
-
Android关闭输入法
-
【android】通话录音 -- service