I'm a Java (Android) beginner (from Python), and I'm trying to catch an exception using Try-Catch as follows:
try { u.save(); } catch (Exception e) { Log.wtf("DO THIS", " WHEN SAVE() FAILS"); }
To my surprise, I do not see my message in the log, but I still get the following error:
09-25 10: 53: 32.147: E / SQLiteDatabase (7991): android.database.sqlite.SQLiteConstraintException: error code 19: restriction not met
Why doesn't he notice the exception? Am I something wrong here? All tips are welcome!
The save () method looks like this:
public final void save() { final SQLiteDatabase db = Cache.openDatabase(); final ContentValues values = new ContentValues(); for (Field field : mTableInfo.getFields()) { final String fieldName = mTableInfo.getColumnName(field); Class<?> fieldType = field.getType(); field.setAccessible(true); try { Object value = field.get(this); if (value != null) { final TypeSerializer typeSerializer = Cache.getParserForType(fieldType); if (typeSerializer != null) {
source share