Fix gpxdatabase
This commit is contained in:
parent
6d717508c4
commit
2e254d6a8d
1 changed files with 6 additions and 4 deletions
|
@ -129,17 +129,19 @@ public class GPXDatabase {
|
||||||
|
|
||||||
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.getVersion() == 0 || DB_VERSION != conn.getVersion()) {
|
int version = conn.getVersion();
|
||||||
|
if (version == 0 || DB_VERSION != version) {
|
||||||
if (readonly) {
|
if (readonly) {
|
||||||
conn.close();
|
conn.close();
|
||||||
conn = context.getSQLiteAPI().getOrCreateDatabase(DB_NAME, readonly);
|
conn = context.getSQLiteAPI().getOrCreateDatabase(DB_NAME, readonly);
|
||||||
}
|
}
|
||||||
if (conn.getVersion() == 0) {
|
version = conn.getVersion();
|
||||||
|
conn.setVersion(DB_VERSION);
|
||||||
|
if (version == 0) {
|
||||||
onCreate(conn);
|
onCreate(conn);
|
||||||
} else {
|
} else {
|
||||||
onUpgrade(conn, conn.getVersion(), DB_VERSION);
|
onUpgrade(conn, version, DB_VERSION);
|
||||||
}
|
}
|
||||||
conn.setVersion(DB_VERSION);
|
|
||||||
}
|
}
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue