aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/DataStore.java
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2014-01-03 15:59:04 +0100
committerSamuel Tardieu <sam@rfc1149.net>2014-01-03 15:59:50 +0100
commite9e7e21f155fa3f547d7acc8df6fb5ba1692a219 (patch)
treec54ee729f5c2edb635cce5cd914466cd70631eb3 /main/src/cgeo/geocaching/DataStore.java
parentdd68dcbc2fa4adc621d932ad1befe89eea65d15e (diff)
downloadcgeo-e9e7e21f155fa3f547d7acc8df6fb5ba1692a219.zip
cgeo-e9e7e21f155fa3f547d7acc8df6fb5ba1692a219.tar.gz
cgeo-e9e7e21f155fa3f547d7acc8df6fb5ba1692a219.tar.bz2
fix #3494: EC attributes disappear on refresh
The lazy loading of attributes appeared after they had been removed from the database.
Diffstat (limited to 'main/src/cgeo/geocaching/DataStore.java')
-rw-r--r--main/src/cgeo/geocaching/DataStore.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/main/src/cgeo/geocaching/DataStore.java b/main/src/cgeo/geocaching/DataStore.java
index 662ce8b..4543451 100644
--- a/main/src/cgeo/geocaching/DataStore.java
+++ b/main/src/cgeo/geocaching/DataStore.java
@@ -1162,15 +1162,19 @@ public class DataStore {
}
private static void saveAttributesWithoutTransaction(final Geocache cache) {
- String geocode = cache.getGeocode();
+ final String geocode = cache.getGeocode();
+
+ // The attributes must be fetched first because lazy loading may load
+ // a null set otherwise.
+ final List<String> attributes = cache.getAttributes();
database.delete(dbTableAttributes, "geocode = ?", new String[]{geocode});
- if (cache.getAttributes().isEmpty()) {
+ if (attributes.isEmpty()) {
return;
}
SQLiteStatement statement = PreparedStatements.getInsertAttribute();
final long timestamp = System.currentTimeMillis();
- for (String attribute : cache.getAttributes()) {
+ for (final String attribute : attributes) {
statement.bindString(1, geocode);
statement.bindLong(2, timestamp);
statement.bindString(3, attribute);