Skip to content

Commit 05289c2

Browse files
committed
Merge pull request #49 from anhr/master
bug of update of database to version 5
2 parents aa8b374 + 73f8399 commit 05289c2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

OpenVehicleApp/src/com/openvehicles/OVMS/ui/utils/Database.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
169169

170170
// copy to db:
171171
for (int i=0; i < notifications.size(); i++) {
172-
addNotificationInt(notifications.get(i));
172+
addNotificationInt(notifications.get(i), db);
173173
}
174174
Log.d(TAG, String.format("Added %d notifications to table.", notifications.size()));
175175

@@ -529,13 +529,18 @@ public void addNotification(NotificationData notificationData) {
529529
open();
530530
addNotificationInt(notificationData);
531531
}
532-
533532
private void addNotificationInt(NotificationData notificationData) {
533+
addNotificationInt(notificationData, db);
534+
}
535+
536+
private void addNotificationInt(NotificationData notificationData, SQLiteDatabase db) {
534537
ContentValues contentValues = new ContentValues();
535538
contentValues.put("nType", notificationData.Type);
536539
contentValues.put("nTimestamp", isoDateTime.format(notificationData.Timestamp));
537540
contentValues.put("nTitle", notificationData.Title);
538541
contentValues.put("nMessage", notificationData.Message);
542+
if(db == null)
543+
throw new NullPointerException( "Open database first." );
539544
db.insert("Notification", null, contentValues);
540545
}
541546

0 commit comments

Comments
 (0)