diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2012-10-07 18:55:41 +0200 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2012-10-07 18:55:41 +0200 |
| commit | 76152432d75f8eb995d094bfd8a1b5e9057d8073 (patch) | |
| tree | da26c8e82461a8b5204749a171caf5e6d464570b /main/src | |
| parent | 91deacc3a396b0d7a6526ea82928b5680dc1c78c (diff) | |
| download | cgeo-76152432d75f8eb995d094bfd8a1b5e9057d8073.zip cgeo-76152432d75f8eb995d094bfd8a1b5e9057d8073.tar.gz cgeo-76152432d75f8eb995d094bfd8a1b5e9057d8073.tar.bz2 | |
fix #2085: trackables can be stored multiple times in database
Diffstat (limited to 'main/src')
| -rw-r--r-- | main/src/cgeo/geocaching/cgData.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java index e2352b8..30ca5f7 100644 --- a/main/src/cgeo/geocaching/cgData.java +++ b/main/src/cgeo/geocaching/cgData.java @@ -1347,12 +1347,16 @@ public class cgData { ContentValues values = new ContentValues(); long timeStamp = System.currentTimeMillis(); for (cgTrackable trackable : trackables) { + final String tbCode = trackable.getGeocode(); + if (StringUtils.isNotBlank(tbCode)) { + database.delete(dbTableTrackables, "tbcode = ?", new String[] { tbCode }); + } values.clear(); if (geocode != null) { values.put("geocode", geocode); } values.put("updated", timeStamp); - values.put("tbcode", trackable.getGeocode()); + values.put("tbcode", tbCode); values.put("guid", trackable.getGuid()); values.put("title", trackable.getName()); values.put("owner", trackable.getOwner()); @@ -1366,7 +1370,7 @@ public class cgData { database.insert(dbTableTrackables, null, values); - saveLogsWithoutTransaction(trackable.getGeocode(), trackable.getLogs()); + saveLogsWithoutTransaction(tbCode, trackable.getLogs()); } } } |
