I have been debugging this problem for hours and I have looked around and cannot seem to find a solution. When I run the code everything works fine except insertNotification is not inserting a new value into the notification table and no exceptions are thrown. Why is this?
public void updateLaw(int lawID, String newSummary, String newFullText){
int tagID = getTagID(lawID);
String tagName = getTagName(tagID);
int categoryID = getCategoryID(tagID);
String categoryName = getCategoryName(categoryID);
openToWrite();
ContentValues contentValues = new ContentValues();
contentValues.put(Constants.KEY_SUMMARY, newSummary);
if(newFullText!=null)
contentValues.put(Constants.KEY_FULL_TEXT, newFullText);
mSqLiteDatabase.update(Constants.TABLE_LAW, contentValues, Constants.KEY_LAW_ID + "=" + lawID, null);
close();
try {
insertNotification(categoryName, tagName + " has changed in " + getLocationName(getLocationID(lawID)));
}
catch(Exception e){
exceptionHandler.alert(e, "UpdateLaw()");
}
}
public void insertNotification(String type, String text){
openToWrite();
try {
mSqLiteDatabase.execSQL("DROP TABLE IF EXISTS notification");
String tableQuery = "CREATE TABLE "+Constants.TABLE_NOTIFICATION+" (\n" +
Constants.KEY_NOTIFICATION_ID +" INTEGER PRIMARY KEY AUTOINCREMENT," +
Constants.KEY_LAW_ID + " INT,\n" +
Constants.KEY_NOTIFICATION_TEXT + " VARCHAR,\n" +
Constants.KEY_NOTIFICATION_TIME + " DATETIME DEFAULT CURRENT_TIMESTAMP,\n" +
Constants.KEY_NOTIFICATION_STATUS + " VARCHAR\n" +
");\n";
mSqLiteDatabase.execSQL(tableQuery);
}
catch(Exception e){
exceptionHandler.alert(e, "insertNotification()");
}
try {
ContentValues contentValues = new ContentValues();
contentValues.put(Constants.KEY_NOTIFICATION_TYPE, type);
contentValues.put(Constants.KEY_NOTIFICATION_TEXT, text);
contentValues.put(Constants.KEY_NOTIFICATION_STATUS, "unread");
mSqLiteDatabase.insert(Constants.TABLE_NOTIFICATION, null, contentValues);
}
catch(Exception e){
exceptionHandler.alert(e, "insertNotification()");
}
close();
}
Aucun commentaire:
Enregistrer un commentaire