aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/cgData.java
diff options
context:
space:
mode:
authorPortree-Kid <keith.paterson@gmx.de>2013-01-22 21:25:52 +0100
committerPortree-Kid <keith.paterson@gmx.de>2013-01-22 21:25:52 +0100
commit6335693959709d1d1f6cd08379e70b726731809a (patch)
treed8975066b63c6807ef406012ee652fc51af7b235 /main/src/cgeo/geocaching/cgData.java
parent14796b42b2b14f799294ba955504bc0064ef5d11 (diff)
downloadcgeo-6335693959709d1d1f6cd08379e70b726731809a.zip
cgeo-6335693959709d1d1f6cd08379e70b726731809a.tar.gz
cgeo-6335693959709d1d1f6cd08379e70b726731809a.tar.bz2
Keep the Waypoint Ids stable. Fixes #2341
Diffstat (limited to 'main/src/cgeo/geocaching/cgData.java')
-rw-r--r--main/src/cgeo/geocaching/cgData.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java
index 94eb3fd..b080f7c 100644
--- a/main/src/cgeo/geocaching/cgData.java
+++ b/main/src/cgeo/geocaching/cgData.java
@@ -1160,7 +1160,6 @@ public class cgData {
private void saveOriginalWaypointsWithoutTransaction(final cgCache cache) {
String geocode = cache.getGeocode();
- database.delete(dbTableWaypoints, "geocode = ? and type <> ? and own = 0", new String[]{geocode, "own"});
List<cgWaypoint> waypoints = cache.getWaypoints();
if (CollectionUtils.isNotEmpty(waypoints)) {
@@ -1183,8 +1182,12 @@ public class cgData {
values.put("note", oneWaypoint.getNote());
values.put("own", oneWaypoint.isUserDefined() ? 1 : 0);
- final long rowId = database.insert(dbTableWaypoints, null, values);
- oneWaypoint.setId((int) rowId);
+ if (oneWaypoint.getId() < 0) {
+ final long rowId = database.insert(dbTableWaypoints, null, values);
+ oneWaypoint.setId((int) rowId);
+ } else {
+ database.update(dbTableWaypoints, values, "_id = ?", new String[] { Integer.toString(oneWaypoint.getId(), 10) });
+ }
}
}
}