Fix NPE's

This commit is contained in:
Victor Shcherb 2018-06-10 18:18:00 +02:00
parent b714389bb3
commit f3a65881e4
2 changed files with 6 additions and 0 deletions

View file

@ -47,6 +47,9 @@ public class DatabaseHelper {
private SQLiteAPI.SQLiteConnection openConnection(boolean readonly) { private SQLiteAPI.SQLiteConnection openConnection(boolean readonly) {
SQLiteAPI.SQLiteConnection conn = app.getSQLiteAPI().getOrCreateDatabase(DB_NAME, readonly); SQLiteAPI.SQLiteConnection conn = app.getSQLiteAPI().getOrCreateDatabase(DB_NAME, readonly);
if (conn == null) {
return null;
}
if (conn.getVersion() == 0 || DB_VERSION != conn.getVersion()) { if (conn.getVersion() == 0 || DB_VERSION != conn.getVersion()) {
if (readonly) { if (readonly) {
conn.close(); conn.close();

View file

@ -112,6 +112,9 @@ public class MapMarkersDbHelper {
private SQLiteConnection openConnection(boolean readonly) { private SQLiteConnection openConnection(boolean readonly) {
SQLiteConnection conn = context.getSQLiteAPI().getOrCreateDatabase(DB_NAME, readonly); SQLiteConnection conn = context.getSQLiteAPI().getOrCreateDatabase(DB_NAME, readonly);
if (conn == null) {
return conn;
}
int version = conn.getVersion(); int version = conn.getVersion();
if (version == 0 || DB_VERSION != version) { if (version == 0 || DB_VERSION != version) {
if (readonly) { if (readonly) {