Code example for SQLException

0
		if (rowId > 0) {
			Uri noteUri = ContentUris.withAppendedId(Hosts.CONTENT_URI, rowId);
			getContext().getContentResolver().notifyChange(noteUri, null);
			return noteUri;
		} 
		throw new SQLException("Failed to insert row into " + uri);
	} 
 
	@Override 
	public int delete(Uri uri, String where, String[] whereArgs) {
		SQLiteDatabase db = mOpenHelper.getWritableDatabase();
		int count;
		switch (sUriMatcher.match(uri)) {
		case HOSTS:
			count = db.delete(HOSTS_TABLE_NAME, where, whereArgs);
			break; 
 
		case HOST_ID:
			String hostId = uri.getPathSegments().get(1);
			count = db.delete(HOSTS_TABLE_NAME, Hosts._ID + "=" + hostId + (!TextUtils.isEmpty(where) ? " AND (" + where + ')' : ""), whereArgs);
			break;