Exemple #1
0
    // ´Ódb  µ½  pref
    public List<Host> get() {
      List<Host> hosts = new LinkedList<Host>();

      SQLiteDatabase db = getReadableDatabase();
      Cursor c = db.query(TABLE_HOSTS, null, null, null, null, null, FIELD_HOSTS_NAME + " ASC");

      while (c.moveToNext()) {
        Host host = new Host();

        host.setId(c.getLong(c.getColumnIndexOrThrow(FIELD_HOSTS_ID)));
        host.setName(c.getString(c.getColumnIndexOrThrow(FIELD_HOSTS_NAME)));
        host.setProtocal(c.getString(c.getColumnIndexOrThrow(FIELD_HOSTS_PROTOCAL)));
        host.setEncoding(c.getString(c.getColumnIndexOrThrow(FIELD_HOSTS_ENCODING)));
        host.setUser(c.getString(c.getColumnIndexOrThrow(FIELD_HOSTS_USER)));
        host.setPass(c.getString(c.getColumnIndexOrThrow(FIELD_HOSTS_PASS)));
        host.setHost(c.getString(c.getColumnIndexOrThrow(FIELD_HOSTS_HOST)));
        host.setPort(c.getInt(c.getColumnIndexOrThrow(FIELD_HOSTS_PORT)));

        host.setRss(c.getString(c.getColumnIndexOrThrow(FIELD_HOSTS_RSS)));
        host.setAquirespan(c.getLong(c.getColumnIndexOrThrow(FIELD_HOSTS_AQUIRESPAN)));
        host.setAlamspan(c.getLong(c.getColumnIndexOrThrow(FIELD_HOSTS_ALARMSPAN)));
        host.setWorkStartTime(c.getLong(c.getColumnIndexOrThrow(FIELD_HOSTS_STARTTIME)));
        host.setWorkEndTime(c.getLong(c.getColumnIndexOrThrow(FIELD_HOSTS_ENDTIME)));
        host.setAlarmInWorktime(c.getInt(c.getColumnIndexOrThrow(FIELD_HOSTS_ALARMINWORKTIME)));

        hosts.add(host);
      }

      c.close();
      db.close();

      return hosts;
    }
Exemple #2
0
    public Host getHost(long id) {
      SQLiteDatabase db = getReadableDatabase();
      Cursor c =
          db.query(
              TABLE_HOSTS,
              null,
              "_id=?",
              new String[] {"" + id},
              null,
              null,
              FIELD_HOSTS_NAME + " ASC");

      Host host = null;
      if (c != null && c.moveToFirst()) {
        host = new Host();

        host.setId(c.getLong(c.getColumnIndexOrThrow(FIELD_HOSTS_ID)));
        host.setName(c.getString(c.getColumnIndexOrThrow(FIELD_HOSTS_NAME)));
        host.setProtocal(c.getString(c.getColumnIndexOrThrow(FIELD_HOSTS_PROTOCAL)));
        host.setEncoding(c.getString(c.getColumnIndexOrThrow(FIELD_HOSTS_ENCODING)));
        host.setUser(c.getString(c.getColumnIndexOrThrow(FIELD_HOSTS_USER)));
        host.setPass(c.getString(c.getColumnIndexOrThrow(FIELD_HOSTS_PASS)));
        host.setHost(c.getString(c.getColumnIndexOrThrow(FIELD_HOSTS_HOST)));
        host.setPort(c.getInt(c.getColumnIndexOrThrow(FIELD_HOSTS_PORT)));

        host.setRss(c.getString(c.getColumnIndexOrThrow(FIELD_HOSTS_RSS)));
        host.setAquirespan(c.getLong(c.getColumnIndexOrThrow(FIELD_HOSTS_AQUIRESPAN)));
        host.setAlamspan(c.getLong(c.getColumnIndexOrThrow(FIELD_HOSTS_ALARMSPAN)));
        host.setWorkStartTime(c.getLong(c.getColumnIndexOrThrow(FIELD_HOSTS_STARTTIME)));
        host.setWorkEndTime(c.getLong(c.getColumnIndexOrThrow(FIELD_HOSTS_ENDTIME)));
        host.setAlarmInWorktime(c.getInt(c.getColumnIndexOrThrow(FIELD_HOSTS_ALARMINWORKTIME)));
      }
      c.close();
      db.close();

      return host;
    }