Let $X=Spec(A)$ be an affine scheme and $U=Spec(R)$ be an affine open subset of $X$. Is it true that $R$ is an localization of $A$, i.e. $R=S^{1}A$ for some closed multiplication subset $S\subset A$ ?

3$\begingroup$ The answers to this question: mathoverflow.net/questions/20782 gives a few correct results in the direction you're asking for. $\endgroup$ – Dan Petersen Jun 12 '13 at 9:30

1$\begingroup$ Three years ago , such a question was asked as follows (see : mathoverflow.net/questions/20782) : "Given a commutative ring A, is there a "ringtheoretic" characterization of the ring homomorphisms A→B that realize Spec(B) as an open affine subscheme of Spec(A) (more precisely, those morphisms such that the induced map Spec(B)→Spec(A) is an open immersion)?" That is the true meaning of the problem ! In Grothendieck's EGA, I myself found nothing. I shall soon ask one of his students ! $\endgroup$ – AlAmrani Jun 13 '13 at 18:27
No. This question is pretty closely related to this other question, but let me give an answer nonetheless:
Consider an elliptic curve $E$ in $\mathbb{P}^2(\mathbb{C})$, choose coordinates $[x:y:z]$ of $\mathbb{P}^2(\mathbb{C})$ in a way that the line $z = 0$ intersects $E$ at an inflection point $O$. Let $X := E \setminus \lbrace z = 0 \rbrace$. Choose a point $P \in E$ such that $P$ is not a torsion point with respect to the group structure on $E$ for which $O$ is the origin. Let $U := X \setminus \lbrace P \rbrace$. Then $U$ is an open affine subset of $X$, but there is no $f \in A:=\mathbb{C}[X]$ that vanishes only at $P$. So $\mathbb{C}[U]$ cannot contain $A_f$ for any nonconstant $f \in A$.

1$\begingroup$ $X$ is certainly affine, but could you explain how you know that $U$ is affine? $\endgroup$ – Zhen Lin Jun 12 '13 at 16:00

3$\begingroup$ By Riemann Roch: any divisor with positive degree on a nonsingular curve is ample, so that $k(O + P)$ is very ample for large $k$, i.e. there exists a curve $D$ on $\mathbb{P}^2(\mathbb{C})$ such that $C \cap D = \lbrace{O,P\rbrace}$. Now use that the complement in a projective variety of a hypersurface is affine. $\endgroup$ – auniket Jun 12 '13 at 16:18
Concerning characterization of an affine open subset U in an affine scheme Spec(A) , with complementary Y, I got the following answer. One uses Serre's affinity criterion. This gives conditions on cohomology whith supports in Y (cohomological dimension). If the ring A is regular, then the characterization is : codim(Y) = 1 purely (Cartier divisor) !.