From 1a10d546c76f474d33e23c5958c08aa0afcdae67 Mon Sep 17 00:00:00 2001 From: sujinwen <sujinwen@454eff88-639b-444f-9e54-f578c98de674> Date: 星期一, 24 七月 2017 11:46:45 +0800 Subject: [PATCH] --- VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/sqlite/PostDao.java | 11 ++++------- 1 files changed, 4 insertions(+), 7 deletions(-) diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/sqlite/PostDao.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/sqlite/PostDao.java index f847ea0..171436d 100644 --- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/sqlite/PostDao.java +++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/sqlite/PostDao.java @@ -8,6 +8,7 @@ import cn.com.basic.face.base.BaseApplication; import cn.com.basic.face.base.Config; +import cn.com.basic.face.base.MainActivity; import cn.com.basic.face.discern.entity.Dictionary; import cn.com.basic.face.discern.query.item.AttendanceQueryItem; @@ -24,27 +25,23 @@ */ public List<Dictionary> loadPostDictionary() { List<Dictionary> list = new ArrayList<Dictionary>(); - SQLiteDatabase db = Config.sqlMap.getDb(); - db.beginTransaction(); + try { String sql = "select a.post_id,a.post_name from post a"; Dictionary aqi = null; - Cursor c = db.rawQuery(sql, new String[]{}); + + Cursor c = MainActivity.getInstance().db.rawQuery(sql, new String[]{}); while (c.moveToNext()) { aqi = new Dictionary(); aqi.setDictId(c.getString(c.getColumnIndex("post_id"))); aqi.setName(c.getString((c.getColumnIndex("post_name")))); list.add(aqi); } - c.close(); - db.setTransactionSuccessful(); }catch (Exception e) { e.printStackTrace(); - }finally { - db.endTransaction(); } return list; } -- Gitblit v1.8.0