use of net.osmand.plus.api.SQLiteAPI.SQLiteConnection in project Osmand by osmandapp.
the class FavouritesDbHelper method editFavouriteNameDB.
public boolean editFavouriteNameDB(FavouritePoint p, String newName, String category) {
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
String oldCategory = p.getCategory();
db.execSQL("UPDATE " + FAVOURITE_TABLE_NAME + " SET " + FAVOURITE_COL_NAME + " = ?, " + FAVOURITE_COL_CATEGORY + "= ? WHERE " + whereNameLatLon(), // $NON-NLS-1$ //$NON-NLS-2$
new Object[] { newName, category, p.getName(), p.getLatitude(), p.getLongitude() });
p.setName(newName);
p.setCategory(category);
if (!oldCategory.equals(category)) {
FavoriteGroup old = flatGroups.get(oldCategory);
if (old != null) {
old.points.remove(p);
}
FavoriteGroup pg = getOrCreateGroup(p, 0);
p.setVisible(pg.visible);
p.setColor(pg.color);
pg.points.add(p);
}
sortAll();
} finally {
db.close();
}
return true;
}
return false;
}
use of net.osmand.plus.api.SQLiteAPI.SQLiteConnection in project Osmand by osmandapp.
the class FavouritesDbHelper method editFavouriteDB.
public boolean editFavouriteDB(FavouritePoint p, double lat, double lon) {
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
db.execSQL("UPDATE " + FAVOURITE_TABLE_NAME + " SET latitude = ?, longitude = ? WHERE " + whereNameLatLon(), // $NON-NLS-1$ //$NON-NLS-2$
new Object[] { lat, lon, p.getName(), p.getLatitude(), p.getLongitude() });
p.setLatitude(lat);
p.setLongitude(lon);
saveCurrentPointsIntoFile();
} finally {
db.close();
}
return true;
}
return false;
}
use of net.osmand.plus.api.SQLiteAPI.SQLiteConnection in project Osmand by osmandapp.
the class FavouritesDbHelper method addFavouriteDB.
public boolean addFavouriteDB(FavouritePoint p) {
if (p.getName().equals("") && flatGroups.containsKey(p.getCategory())) {
return true;
}
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
db.execSQL("INSERT INTO " + FAVOURITE_TABLE_NAME + " (" + FAVOURITE_COL_NAME + ", " + FAVOURITE_COL_CATEGORY + ", " + FAVOURITE_COL_LAT + ", " + FAVOURITE_COL_LON + ")" + " VALUES (?, ?, ?, ?)", // $NON-NLS-1$ //$NON-NLS-2$
new Object[] { p.getName(), p.getCategory(), p.getLatitude(), p.getLongitude() });
FavoriteGroup group = getOrCreateGroup(p, 0);
if (!p.getName().equals("")) {
p.setVisible(group.visible);
p.setColor(group.color);
group.points.add(p);
cachedFavoritePoints.add(p);
}
saveCurrentPointsIntoFile();
} finally {
db.close();
}
return true;
}
return false;
}
use of net.osmand.plus.api.SQLiteAPI.SQLiteConnection in project Osmand by osmandapp.
the class MapMarkersDbHelper method getMarker.
@Nullable
public MapMarker getMarker(String id) {
MapMarker res = null;
SQLiteConnection db = openConnection(true);
if (db != null) {
try {
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ID + " = ?", new String[] { id });
if (query.moveToFirst()) {
res = readItem(query);
}
query.close();
} finally {
db.close();
}
}
return res;
}
use of net.osmand.plus.api.SQLiteAPI.SQLiteConnection in project Osmand by osmandapp.
the class MapMarkersDbHelper method updateMarker.
public void updateMarker(MapMarker marker) {
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
String descr = PointDescription.serializeToString(marker.getOriginalPointDescription());
db.execSQL("UPDATE " + MARKERS_TABLE_NAME + " SET " + MARKERS_COL_LAT + " = ?, " + MARKERS_COL_LON + " = ?, " + MARKERS_COL_DESCRIPTION + " = ?, " + MARKERS_COL_COLOR + " = ?, " + MARKERS_COL_SELECTED + " = ? " + "WHERE " + MARKERS_COL_ID + " = ?", new Object[] { marker.getLatitude(), marker.getLongitude(), descr, marker.colorIndex, marker.selected, marker.id });
} finally {
db.close();
}
}
}
Aggregations