public ArrayList<RecordInfo> queryAll() { ArrayList<RecordInfo> list = new ArrayList<RecordInfo>(); Cursor cursor = db.query(table, null, null, null, null, null, null); for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { list.add(getInfo(cursor)); } return list; }
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 int update(RecordInfo record) { ContentValues values = new ContentValues(); values.put("connect", record.connect); values.put("size", record.size); values.put("links", record.links); values.put("scripts", record.scripts); values.put("updateTime", record.updateTime); values.put("streamLength", record.streamLength); values.put("status", record.status); return db.update(table, values, "recordId=?", new String[] {String.valueOf(record.recordId)}); }
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; }
public int add(RecordInfo record) { ContentValues values = new ContentValues(); // values.put("siteId", record.siteId); values.put("siteId", record.siteId); values.put("addTime", record.addTime); values.put("source", record.source); values.put("connect", record.connect); values.put("size", record.size); values.put("links", record.links); values.put("scripts", record.scripts); values.put("updateTime", record.updateTime); values.put("streamLength", record.streamLength); values.put("status", record.status); return (int) db.insert(table, values); }
public void close() { db.close(); }
public int delete(int recordId) { return db.delete(table, "recordId=?", new String[] {String.valueOf(recordId)}); }