From 2e254d6a8dcf7ed1c658d3765b2674a4072fe308 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Fri, 7 Jul 2017 20:43:26 +0300 Subject: [PATCH] Fix gpxdatabase --- OsmAnd/src/net/osmand/plus/GPXDatabase.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/GPXDatabase.java b/OsmAnd/src/net/osmand/plus/GPXDatabase.java index 5f01edf9d8..c3539cd40f 100644 --- a/OsmAnd/src/net/osmand/plus/GPXDatabase.java +++ b/OsmAnd/src/net/osmand/plus/GPXDatabase.java @@ -129,17 +129,19 @@ public class GPXDatabase { private SQLiteConnection openConnection(boolean readonly) { SQLiteConnection conn = context.getSQLiteAPI().getOrCreateDatabase(DB_NAME, readonly); - if (conn.getVersion() == 0 || DB_VERSION != conn.getVersion()) { + int version = conn.getVersion(); + if (version == 0 || DB_VERSION != version) { if (readonly) { conn.close(); conn = context.getSQLiteAPI().getOrCreateDatabase(DB_NAME, readonly); } - if (conn.getVersion() == 0) { + version = conn.getVersion(); + conn.setVersion(DB_VERSION); + if (version == 0) { onCreate(conn); } else { - onUpgrade(conn, conn.getVersion(), DB_VERSION); + onUpgrade(conn, version, DB_VERSION); } - conn.setVersion(DB_VERSION); } return conn; }