示例#1
0
  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;
  }
示例#2
0
 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;
 }
示例#3
0
  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)});
  }
示例#4
0
 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;
 }
示例#5
0
  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;
  }
示例#6
0
  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);
  }
示例#7
0
 public void close() {
   db.close();
 }
示例#8
0
 public int delete(int recordId) {
   return db.delete(table, "recordId=?", new String[] {String.valueOf(recordId)});
 }