Browse Source

fixed db bug

Julien Clauter 9 years ago
parent
commit
b25ac373b5

+ 8 - 4
src/de/tudarmstadt/informatik/hostage/persistence/HostageDBOpenHelper.java

@@ -199,8 +199,13 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
                 record.setLast_sync_timestamp(cursor.getLong(1));
                 record.setHighest_attack_id(cursor.getLong(2));
                 thisDevice = record;
-
+                cursor.close();
+                db.close();
+                // return record list
             } else {
+                cursor.close();
+                db.close();
+
                 // CREATE A NEW SYNC DEVICE
                 thisDevice = new SyncDevice();
                 // ITS IMPORTANT TO CREATE A COMPLETE NEW DEVICE UUID
@@ -215,10 +220,9 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
                 devices.add(thisDevice);
                 this.insertSyncDevices(devices);
             }
-            cursor.close();
 
-            // return record list
-            db.close();
+
+
         }
 
         thisDevice.setHighest_attack_id(attack_id - 1);