From dea014a98bec51049346f3a3b05f59c1d05d8db7 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Fri, 5 Jun 2020 16:49:15 +0300 Subject: [PATCH] Fix possible SQLiteException --- .../osmand/plus/srtmplugin/TerrainLayer.java | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainLayer.java b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainLayer.java index f55613d1bc..bdfe5e4772 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainLayer.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainLayer.java @@ -1,28 +1,5 @@ package net.osmand.plus.srtmplugin; -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import net.osmand.IndexConstants; -import net.osmand.PlatformUtil; -import net.osmand.data.QuadRect; -import net.osmand.data.QuadTree; -import net.osmand.data.RotatedTileBox; -import net.osmand.map.TileSourceManager.TileSourceTemplate; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.settings.backend.OsmandSettings.TerrainMode; -import net.osmand.plus.SQLiteTileSource; -import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.api.SQLiteAPI.SQLiteConnection; -import net.osmand.plus.views.MapTileLayer; -import net.osmand.util.Algorithms; - -import org.apache.commons.logging.Log; - import android.annotation.SuppressLint; import android.content.ContentValues; import android.database.Cursor; @@ -31,6 +8,29 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.os.AsyncTask; +import net.osmand.IndexConstants; +import net.osmand.PlatformUtil; +import net.osmand.data.QuadRect; +import net.osmand.data.QuadTree; +import net.osmand.data.RotatedTileBox; +import net.osmand.map.TileSourceManager.TileSourceTemplate; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.SQLiteTileSource; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.api.SQLiteAPI.SQLiteConnection; +import net.osmand.plus.settings.backend.OsmandSettings.TerrainMode; +import net.osmand.plus.views.MapTileLayer; +import net.osmand.util.Algorithms; + +import org.apache.commons.logging.Log; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + import static net.osmand.plus.settings.backend.OsmandSettings.TerrainMode.HILLSHADE; public class TerrainLayer extends MapTileLayer { @@ -86,11 +86,11 @@ public class TerrainLayer extends MapTileLayer { new File(cacheDir, mode == HILLSHADE ? HILLSHADE_CACHE : SLOPE_CACHE).getPath(), null, SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING | SQLiteDatabase.CREATE_IF_NECESSARY ); - if(sqliteDb.getVersion() == 0) { + if (sqliteDb.getVersion() == 0) { sqliteDb.setVersion(1); - sqliteDb.execSQL("CREATE TABLE TILE_SOURCES(filename varchar2(256), date_modified int, left int, right int, top int, bottom int)"); } - + sqliteDb.execSQL("CREATE TABLE IF NOT EXISTS TILE_SOURCES(filename varchar2(256), date_modified int, left int, right int, top int, bottom int)"); + Map fileModified = new HashMap(); Map rs = readFiles(app, tilesDir, fileModified); indexCachedResources(fileModified, rs);