コード例 #1
0
 public void UpdateWindStat(WindData windStat, int id, DbHandle handle) {
   SQLiteDatabase db = handle.getDb();
   ContentValues cv = new ContentValues();
   cv.put(COL_DAY, windStat.getDay());
   cv.put(COL_SPOT, windStat.getSpotID());
   cv.put(COL_HOUR, windStat.getEndHour());
   cv.put(COL_MINUTE, windStat.getEndMinute());
   cv.put(COL_START_HOUR, windStat.getStartHour());
   cv.put(COL_START_MINUTE, windStat.getStartMinute());
   cv.put(COL_WIND, windStat.getWind());
   cv.put(COL_GUST, windStat.getGust());
   cv.put(COL_ANGLE, windStat.getAngle());
   cv.put(COL_LAST_MODIFIED, windStat.getLastModified());
   db.update(WINDTABLE, cv, COL_ID + "=?", new String[] {"" + id});
 }
コード例 #2
0
 public void InsertWindStat(WindData windStat, DbHandle handle) {
   SQLiteDatabase db = handle.getDb();
   ContentValues cv = new ContentValues();
   cv.put(COL_SPOT, windStat.getSpotID());
   cv.put(COL_DAY, windStat.getDay());
   cv.put(COL_HOUR, windStat.getEndHour());
   cv.put(COL_MINUTE, windStat.getEndMinute());
   cv.put(COL_START_HOUR, windStat.getStartHour());
   cv.put(COL_START_MINUTE, windStat.getStartMinute());
   cv.put(COL_WIND, windStat.getWind());
   cv.put(COL_GUST, windStat.getGust());
   cv.put(COL_ANGLE, windStat.getAngle());
   cv.put(COL_LAST_MODIFIED, windStat.getLastModified());
   db.insert(WINDTABLE, null, cv);
 }
コード例 #3
0
 public void insertOrUpdateWindStat(WindData windStat, DbHandle handle) {
   // find if row already exists
   Cursor cursor =
       getWindStatsOfDayAndTime(
           windStat.getSpotID(),
           windStat.getDay(),
           windStat.getEndHour(),
           windStat.getEndMinute(),
           handle);
   if (cursor.moveToFirst()) {
     // already exists, do an update
     int id = cursor.getInt(cursor.getColumnIndex(COL_ID));
     UpdateWindStat(windStat, id, handle);
   } else {
     // insert new row
     InsertWindStat(windStat, handle);
   }
   cursor.close();
 }