public RecordInfo query(int recordId) { Cursor cursor = db.rawQuery( "select * from record where recordId = ?", new String[] {String.valueOf(recordId)}); RecordInfo record = null; if (cursor.moveToFirst()) { record = getInfo(cursor); } else { record = new RecordInfo(); } return record; }
public RecordInfo querySiteRecord(int siteId) { Cursor cursor = db.rawQuery( "select * from record where siteId = ? order by recordId desc limit 1", new String[] {String.valueOf(siteId)}); RecordInfo record = null; if (cursor.moveToFirst()) { record = getInfo(cursor); } else { record = new RecordInfo(); } return record; }
public ArrayList<RecordInfo> querySiteAllRecord(int siteId, int pageSize, int page) { int start = (page - 1) * pageSize; Cursor cursor = db.rawQuery( "select * from record where siteId = ? order by recordId desc limit ? offset ?", new String[] {String.valueOf(siteId), String.valueOf(pageSize), String.valueOf(start)}); ArrayList<RecordInfo> list = new ArrayList<RecordInfo>(); for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { list.add(getInfo(cursor)); } return list; }