diff --git a/Vibernate-2/src/main/java/com/napontaratan/vibernate/database/VibernateDB.java b/Vibernate-2/src/main/java/com/napontaratan/vibernate/database/VibernateDB.java index f4f620f..8896346 100644 --- a/Vibernate-2/src/main/java/com/napontaratan/vibernate/database/VibernateDB.java +++ b/Vibernate-2/src/main/java/com/napontaratan/vibernate/database/VibernateDB.java @@ -74,7 +74,7 @@ public void addToDB(TimerSession timerSession) { try { values.put(KEY_ID, timerSession.getId()); - values.put(KEY_ALARM, TimerUtils.serialize(timerSession)); + values.put(KEY_ALARM, TimerSession.serialize(timerSession)); } catch (Exception e) { e.printStackTrace(); } @@ -88,7 +88,7 @@ public void updateTimerInDB(TimerSession timerSession) { ContentValues values = new ContentValues(); try { - values.put(KEY_ALARM, TimerUtils.serialize(timerSession)); + values.put(KEY_ALARM, TimerSession.serialize(timerSession)); } catch (Exception e) { e.printStackTrace(); } @@ -113,14 +113,15 @@ public List getAllTimers() { if (cursor.moveToFirst()) { do { try { - timerSession = (TimerSession) TimerUtils.deserialize(cursor.getBlob(1)); + timerSession = (TimerSession) TimerSession.deserialize(cursor.getBlob(1)); + result.add(timerSession); } catch (ClassNotFoundException e) { e.printStackTrace(); + db.delete(TABLE_NAME, null, null); + break; } catch (IOException e) { e.printStackTrace(); - } - - result.add(timerSession); + } } while (cursor.moveToNext()); } return result;