use of net.osmand.plus.api.SQLiteAPI.SQLiteConnection in project Osmand by osmandapp.
the class MapMarkersDbHelper method updateGroupDisabled.
public void updateGroupDisabled(String id, boolean disabled) {
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
db.execSQL("UPDATE " + GROUPS_TABLE_NAME + " SET " + GROUPS_COL_DISABLED + " = ? " + "WHERE " + GROUPS_COL_ID + " = ?", new Object[] { disabled ? 1 : 0, id });
db.execSQL("UPDATE " + MARKERS_TABLE_NAME + " SET " + MARKERS_COL_DISABLED + " = ? " + "WHERE " + MARKERS_COL_GROUP_KEY + " = ?", new Object[] { disabled ? 1 : 0, id });
} finally {
db.close();
}
}
}
use of net.osmand.plus.api.SQLiteAPI.SQLiteConnection in project Osmand by osmandapp.
the class MapMarkersDbHelper method moveMarkerToHistory.
public void moveMarkerToHistory(MapMarker marker) {
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
marker.visitedDate = System.currentTimeMillis();
db.execSQL("UPDATE " + MARKERS_TABLE_NAME + " SET " + MARKERS_COL_ACTIVE + " = ?, " + MARKERS_COL_VISITED + " = ?, " + MARKERS_COL_NEXT_KEY + " = ? " + "WHERE " + MARKERS_COL_ID + " = ?", new Object[] { 0, marker.visitedDate, HISTORY_NEXT_VALUE, marker.id });
} finally {
db.close();
}
}
}
use of net.osmand.plus.api.SQLiteAPI.SQLiteConnection in project Osmand by osmandapp.
the class MapMarkersDbHelper method getMarkersHistory.
public List<MapMarker> getMarkersHistory() {
List<MapMarker> markers = new ArrayList<>();
SQLiteConnection db = openConnection(true);
if (db != null) {
try {
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ?", new String[] { String.valueOf(0) });
if (query.moveToFirst()) {
do {
markers.add(readItem(query));
} while (query.moveToNext());
}
query.close();
} finally {
db.close();
}
}
return markers;
}
use of net.osmand.plus.api.SQLiteAPI.SQLiteConnection in project Osmand by osmandapp.
the class MapMarkersDbHelper method removeDisabledGroups.
public void removeDisabledGroups() {
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
db.execSQL("DELETE FROM " + GROUPS_TABLE_NAME + " WHERE " + GROUPS_COL_DISABLED + " = ? ", new Object[] { 1 });
db.execSQL("DELETE FROM " + MARKERS_TABLE_NAME + " WHERE " + MARKERS_COL_DISABLED + " = ? AND " + MARKERS_COL_ACTIVE + " = ?", new Object[] { 1, 1 });
} finally {
db.close();
}
}
}
use of net.osmand.plus.api.SQLiteAPI.SQLiteConnection in project Osmand by osmandapp.
the class GPXDatabase method updateAnalysis.
public boolean updateAnalysis(GpxDataItem item, GPXTrackAnalysis a) {
SQLiteConnection db = openConnection(false);
if (db != null && a != null) {
try {
String fileName = getFileName(item.file);
String fileDir = getFileDir(item.file);
db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_TOTAL_DISTANCE + " = ?, " + GPX_COL_TOTAL_TRACKS + " = ?, " + GPX_COL_START_TIME + " = ?, " + GPX_COL_END_TIME + " = ?, " + GPX_COL_TIME_SPAN + " = ?, " + GPX_COL_TIME_MOVING + " = ?, " + GPX_COL_TOTAL_DISTANCE_MOVING + " = ?, " + GPX_COL_DIFF_ELEVATION_UP + " = ?, " + GPX_COL_DIFF_ELEVATION_DOWN + " = ?, " + GPX_COL_AVG_ELEVATION + " = ?, " + GPX_COL_MIN_ELEVATION + " = ?, " + GPX_COL_MAX_ELEVATION + " = ?, " + GPX_COL_MAX_SPEED + " = ?, " + GPX_COL_AVG_SPEED + " = ?, " + GPX_COL_POINTS + " = ?, " + GPX_COL_WPT_POINTS + " = ?, " + GPX_COL_FILE_LAST_MODIFIED_TIME + " = ?, " + GPX_COL_WPT_CATEGORY_NAMES + " = ? " + " WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?", new Object[] { a.totalDistance, a.totalTracks, a.startTime, a.endTime, a.timeSpan, a.timeMoving, a.totalDistanceMoving, a.diffElevationUp, a.diffElevationDown, a.avgElevation, a.minElevation, a.maxElevation, a.maxSpeed, a.avgSpeed, a.points, a.wptPoints, item.file.lastModified(), Algorithms.encodeStringSet(a.wptCategoryNames), fileName, fileDir });
} finally {
db.close();
}
return true;
}
return false;
}
Aggregations