try to wrap db
This commit is contained in:
parent
ada8c2a998
commit
846bd3fcfa
1 changed files with 13 additions and 5 deletions
|
@ -1,15 +1,19 @@
|
||||||
package net.osmand.plus.api;
|
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.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
|
|
||||||
public class SQLiteAPIImpl implements SQLiteAPI {
|
public class SQLiteAPIImpl implements SQLiteAPI {
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
|
private static final Log LOG = PlatformUtil.getLog(SQLiteAPIImpl.class);
|
||||||
|
|
||||||
public SQLiteAPIImpl(OsmandApplication app) {
|
public SQLiteAPIImpl(OsmandApplication app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
@ -18,9 +22,13 @@ public class SQLiteAPIImpl implements SQLiteAPI {
|
||||||
@SuppressLint("InlinedApi")
|
@SuppressLint("InlinedApi")
|
||||||
@Override
|
@Override
|
||||||
public SQLiteConnection getOrCreateDatabase(String name, boolean readOnly) {
|
public SQLiteConnection getOrCreateDatabase(String name, boolean readOnly) {
|
||||||
android.database.sqlite.SQLiteDatabase db = app.openOrCreateDatabase(name,
|
android.database.sqlite.SQLiteDatabase db = null;
|
||||||
Context.MODE_PRIVATE |
|
try {
|
||||||
(readOnly ? 0 : Context.MODE_ENABLE_WRITE_AHEAD_LOGGING), null);
|
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) {
|
if(db == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue