Skip to content

Commit 610cc48

Browse files
author
Jana Hoch
committed
Fix app crash on upgrade.
1 parent 0669331 commit 610cc48

File tree

1 file changed

+8
-0
lines changed
  • app/src/main/java/com/blogspot/e_kanivets/moneytracker/repo

1 file changed

+8
-0
lines changed

app/src/main/java/com/blogspot/e_kanivets/moneytracker/repo/DbHelper.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
169169
/* Add notes column to the records table */
170170
db.execSQL("ALTER TABLE " + TABLE_RECORDS + " ADD COLUMN "
171171
+ NOTES_COLUMN + " TEXT;");
172+
173+
/* Set the notes as empty string for all the record*/
174+
ContentValues contentValues = new ContentValues();
175+
contentValues.put(NOTES_COLUMN, "");
176+
db.update(DbHelper.TABLE_RECORDS, contentValues, null, null);
177+
178+
db.setTransactionSuccessful();
179+
db.endTransaction();
172180
}
173181
}
174182

0 commit comments

Comments
 (0)