For a simple, really concrete example you can also look at:
$A=k[X,Y,U,V]/(XY+UX^2+VY^2)$$A=k[x,y,u,v]/(xy+ux^2+vy^2)$, $X =Spec(A)$, $I=(X,Y)$$I=(x,y)$, $U = D(I)$.
Then the functions $f=-V/X=(Y+UX)/Y^2$$f=\frac{-v}{x}=\frac{y+ux}{y^2}$ and $g=-U/Y=(X+VY)/X^2$$g=\frac{-u}{y}=\frac{x+vy}{x^2}$ are defined on $U$. But $Yf+Xg=1$ $yf+xg=1$, so $U$ is affine!
Cheers,