I have a question about the Exercise 4.3.B of Vakil's Foundations of Algebraic Geometry. The problems asks for a natural isomorphism $(D(f),\mathcal O_{\operatorname {Spec}A}|_{D(f)})\cong (\operatorname{Spec}A_f,\mathcal O_{\operatorname {Spec}A_f})$.
My question is about the proof of the sheaf isomorphism $\mathcal O_{\operatorname {Spec}A}|_{D(f)}\cong \mathcal O_{\operatorname {Spec}A_f}$.
I tried to prove the isomorphism on the base (the distinguished open sets $D(g)$). Take $D(g)\subset D(f)$. Specifically, I want to show the following two sets are naturally isomorphic:
$$\mathcal O_{\operatorname {Spec}A}|_{D(f)}(D(g))=\{h\in A:D(g)\subset D(h)\}.$$ $$\mathcal O_{\operatorname {Spec}A_f}(D(g/1))=\{a/f^n\in A_f:D(g/1)\subset D(a/f^n)\}.$$
$h \mapsto h/1$ gives the map from the first one to the second one. But I have trouble showing that this map is bijective (even the injectivity confused me).
Any other approach to this problem is also appreciated!