Пример #1
0
  // Load all check-in data on specified date
  public synchronized DBError loadCheckinDataList(ArrayList<CheckInData> dataList) {
    // clear all favorite list
    Assert.assertTrue(dataList != null);
    dataList.clear();

    try {
      String rawQuery = "select * from tbl_checkin order by time";
      Cursor listCursor = mDatabase.rawQuery(rawQuery, null);

      if (listCursor == null) return DBError.DB_ERROR_FAILED;

      if (listCursor.getCount() > 0) {
        while (listCursor.moveToNext() == true) {
          CheckInData newData = new CheckInData();
          newData.lat = listCursor.getDouble(listCursor.getColumnIndex("lat"));
          newData.lng = listCursor.getDouble(listCursor.getColumnIndex("lng"));
          newData.time = listCursor.getLong(listCursor.getColumnIndex("time"));
          newData.place = listCursor.getString(listCursor.getColumnIndex("place"));

          dataList.add(newData);
        }
      }

      // Close query
      listCursor.close();
    } catch (SQLiteException e) {
      return DBError.DB_ERROR_FAILED;
    }

    return DBError.DB_ERROR_NONE;
  }
Пример #2
0
  // Load all check-in data on specified date
  public synchronized DBError loadCheckinDataListOnDate(
      ArrayList<CheckInData> dataList, long date) {
    // clear all favorite list
    Assert.assertTrue(dataList != null);
    dataList.clear();

    long startTime;
    long endTime;

    startTime = Utility.getDateTimeMilis(date);
    endTime = startTime + Constant.DATE_MILISECONDS;
    try {
      String rawQuery =
          "select * from tbl_checkin where time >= "
              + startTime
              + " and time < "
              + endTime
              + " order by time";
      Cursor listCursor = mDatabase.rawQuery(rawQuery, null);

      if (listCursor == null) return DBError.DB_ERROR_FAILED;

      if (listCursor.getCount() > 0) {
        while (listCursor.moveToNext() == true) {
          CheckInData newData = new CheckInData();
          newData.lat = listCursor.getDouble(listCursor.getColumnIndex("lat"));
          newData.lng = listCursor.getDouble(listCursor.getColumnIndex("lng"));
          newData.time = listCursor.getLong(listCursor.getColumnIndex("time"));
          newData.place = listCursor.getString(listCursor.getColumnIndex("place"));

          dataList.add(newData);
        }
      }

      // Close query
      listCursor.close();
    } catch (SQLiteException e) {
      return DBError.DB_ERROR_FAILED;
    }

    return DBError.DB_ERROR_NONE;
  }