Code example for SQLException

0
            rowId = dbHelper.getWritableDatabase().insert(table, null, insertValues);
        } 
        if (rowId > 0) {
            return rowId;
        } 
        throw new SQLException("Failed to insert row into " + uri);
    } 
 
    private long tryUpdateWithConstrain(String table, String constrain, ContentValues values) {
        long rowId = -1;
        int update = dbHelper.getWritableDatabase().update(table, values, constrain + "=?",
                new String[] {
                values.getAsString(constrain)
        }); 
 
        if (Log.Provider.verboseLoggingEnabled()) { 
            Log.Provider.v("Constrain " + constrain + " yield " + update);
        } 
        if (update > 0) {
            rowId = getRowIdForUpdate(table, constrain, values);
        }