From c94c8f21adde9efee835d31b168e7a342c0a8473 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 29 May 2018 10:25:35 +0200 Subject: [PATCH] try to wrap db --- .../src/net/osmand/plus/api/SQLiteAPIImpl.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java b/OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java index 8ed2827e6b..7199388596 100644 --- a/OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java +++ b/OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java @@ -1,15 +1,19 @@ package net.osmand.plus.api; +import net.osmand.PlatformUtil; +import net.osmand.plus.OsmandApplication; + +import org.apache.commons.logging.Log; + import android.annotation.SuppressLint; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; -import net.osmand.plus.OsmandApplication; - public class SQLiteAPIImpl implements SQLiteAPI { private OsmandApplication app; + private static final Log LOG = PlatformUtil.getLog(SQLiteAPIImpl.class); public SQLiteAPIImpl(OsmandApplication app) { this.app = app; @@ -18,9 +22,13 @@ public class SQLiteAPIImpl implements SQLiteAPI { @SuppressLint("InlinedApi") @Override public SQLiteConnection getOrCreateDatabase(String name, boolean readOnly) { - android.database.sqlite.SQLiteDatabase db = app.openOrCreateDatabase(name, - Context.MODE_PRIVATE | - (readOnly ? 0 : Context.MODE_ENABLE_WRITE_AHEAD_LOGGING), null); + android.database.sqlite.SQLiteDatabase db = null; + try { + db = app.openOrCreateDatabase(name, Context.MODE_PRIVATE + | (readOnly ? 0 : Context.MODE_ENABLE_WRITE_AHEAD_LOGGING), null); + } catch (RuntimeException e) { + LOG.error(e.getMessage(), e); + } if(db == null) { return null; }