public long createPOI(POI poi, long track_id) { SQLiteDatabase database = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put("order_id", poi.order_id); values.put("latitude", poi.getLatitude()); values.put("longitude", poi.getLongitude()); values.put("altitude", poi.getAltitude()); values.put("time", poi.getTime()); values.put("accuracy", poi.getAccuracy()); values.put("id_track", track_id); long POI_id = database.insert(TABLE_POINT, null, values); return POI_id; }
public void createPOIs(ArrayList<POI> pois, long track_id) { SQLiteDatabase database = this.getWritableDatabase(); ContentValues values = new ContentValues(); for (POI poi : pois) { values.put("order_id", poi.order_id); values.put("latitude", poi.getLatitude()); values.put("longitude", poi.getLongitude()); values.put("altitude", poi.getAltitude()); values.put("time", poi.getTime()); values.put("accuracy", poi.getAccuracy()); values.put("id_track", track_id); database.insert(TABLE_POINT, null, values); } }
public List<POI> getPOIs(long track_id) { SQLiteDatabase database = this.getWritableDatabase(); List<POI> pois = new ArrayList<POI>(); String select = "SELECT * FROM point where id_track=" + track_id; Cursor cursor = database.rawQuery(select, null); if (cursor.moveToFirst()) { do { POI poi = new POI(""); poi.order_id = (cursor.getInt(1)); poi.setLatitude(cursor.getDouble(2)); poi.setLongitude(cursor.getDouble(3)); poi.setAltitude(cursor.getDouble(4)); poi.setTime(cursor.getLong(5)); poi.setAccuracy(cursor.getFloat(6)); pois.add(poi); } while (cursor.moveToFirst()); } return pois; }