示例#1
0
  /** 更新轨迹地图 11-22 */
  public int updateMapAddressFromData(
      int map_id, JSONArray points, List<Record> recordList, SQLiteDatabase db) {
    int update = -1;

    String googlemapaddress = Utils.generateMapAddress(recordList, null, 400, true);
    ContentValues updateValues = new ContentValues();
    updateValues.put("googlemap", googlemapaddress);
    updateValues.put("points", points.toString());
    updateValues.put("name", Utils.getNowTime().substring(0, 10) + "的骑行");
    update = db.update("map", updateValues, "id = ?", new String[] {map_id + ""});

    // 发消息
    // 插入一条数据到主列表中
    //		insertMainData("map",data.getMap_id(),Utils.getNowTime(),data.getAction_id(),data,db);
    insertMessage("map", map_id, Utils.getNowTime(), 1, db);

    return update;
  }
示例#2
0
  public int insertLocation(AllData data, SQLiteDatabase db) {
    List<Record> recordList = new ArrayList<Record>();
    Record r = new Record();
    r.setLatitude(data.getNowLatLng().latitude);
    r.setLongitude(data.getNowLatLng().longitude);
    recordList.add(r);

    String googlemapaddress = Utils.generateMapAddress(recordList, null, 400, true);
    String sql =
        "insert into location(latitude,longitude,googlemap,create_time,address) "
            + "values(?,?,?,?,?)";
    //		String create_date=Utils.getNowTime();
    String create_date = data.getCreate_Date();
    db.execSQL(
        sql,
        new Object[] {
          data.getNowLatLng().latitude + "",
          data.getNowLatLng().longitude + "",
          googlemapaddress,
          create_date,
          data.getAddress()
        });

    Cursor cursor = db.rawQuery("select last_insert_rowid() from location", null);
    int strid = -1;

    try {
      if (cursor.moveToFirst()) {
        strid = cursor.getInt(0);
      }
    } finally {
      cursor.close();
    }

    return strid;
  }