Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static final String READINGS_CREATE = "CREATE TABLE 'readings' ('building_id' TEXT NOT NULL , "
- + "'position_id' TEXT NOT NULL , 'x' FLOAT NOT NULL, 'y' FLOAT NOT NULL, "
- + " 'ssid' TEXT NOT NULL , 'mac_id' TEXT NOT NULL , 'rssi' INTEGER NOT NULL )";
- public ArrayList<String> getPositions(String building_id) {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.rawQuery("select distinct position_id from "
- + READINGS_TABLE + " where building_id=?",
- new String[] { building_id });
- ArrayList<String> result = new ArrayList<String>();
- cursor.moveToFirst();
- while (cursor.isAfterLast() == false) {
- result.add(cursor.getString(0));
- cursor.moveToNext();
- }
- return result;
- }
- public boolean addReadings(String building_id, PositionData positionData) {
- Log.v("Just Before db : ", positionData.toString());
- deleteReading(building_id, positionData.getName());
- SQLiteDatabase db = getWritableDatabase();
- for (Map.Entry<String, Integer> e : positionData.getValues().entrySet()) {
- ContentValues cv = new ContentValues();
- cv.put("building_id", building_id);
- cv.put("position_id", positionData.getName());
- cv.put("ssid",positionData.routers.get(e.getKey()));
- cv.put("mac_id",e.getKey());
- cv.put("rssi", e.getValue());
- cv.put("x", positionData.getX());
- cv.put("y", positionData.getY());
- Log.v(e.getKey(), e.getValue().toString());
- db.insert(READINGS_TABLE, null, cv);
- }
- System.out.println("Adding done");
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement