diff options
Diffstat (limited to 'main/src/cgeo/geocaching/DataStore.java')
| -rw-r--r-- | main/src/cgeo/geocaching/DataStore.java | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/main/src/cgeo/geocaching/DataStore.java b/main/src/cgeo/geocaching/DataStore.java index 5cc77dc..f4d2126 100644 --- a/main/src/cgeo/geocaching/DataStore.java +++ b/main/src/cgeo/geocaching/DataStore.java @@ -294,18 +294,22 @@ public class DataStore { private static boolean newlyCreatedDatabase = false; private static boolean databaseCleaned = false; - public synchronized static void init() { + public static void init() { if (database != null) { return; } - final DbHelper dbHelper = new DbHelper(new DBContext(CgeoApplication.getInstance())); - try { - database = dbHelper.getWritableDatabase(); - } catch (Exception e) { - Log.e("DataStore.init: unable to open database for R/W", e); - recreateDatabase(dbHelper); - + synchronized(DataStore.class) { + if (database != null) { + return; + } + final DbHelper dbHelper = new DbHelper(new DBContext(CgeoApplication.getInstance())); + try { + database = dbHelper.getWritableDatabase(); + } catch (Exception e) { + Log.e("DataStore.init: unable to open database for R/W", e); + recreateDatabase(dbHelper); + } } } |
