Let $A$ be commutative ring with unit and M,N be two finitely presented modules over $A$. I want to show that if $M_{\mathfrak{p}} \cong N_{\mathfrak{p}}$ for some prime ideal $\mathfrak{p}$ of $A$ then there exists $f \in A \backslash \mathfrak{p}$ such that $M_f \cong N_f$.
I know the following results :
$Hom_{A_\mathfrak{p}}(M_\mathfrak{p},N_\mathfrak{p}) \cong Hom_A(M,N)_\mathfrak{p}$
and
$M_\mathfrak{p} =0$ implies that there exists $f \in A \backslash \mathfrak{p}$ such that $M_f = 0$.
Here is the idea I have :
Suppose $g : M_\mathfrak{p} \to N_\mathfrak{p}$ is an isomorphism then lift $g$ to a morphism $g' : M \to N$ then $\ker(g')_\mathfrak{p} = 0$ and coker$(g')_\mathfrak{p}=0$ then there exist $f_1,f_2 \in A \backslash \mathfrak{p}$ such that $\ker(g')_{f_1} = 0$ and coker$(g')_{f_2}=0$. Take $f=f_1f_2$ then $\ker(g')_{f} = 0$ and coker$(g')_{f}=0$ which means that $g'_f : M_f \to N_f$ gives an isomorphism.
My question is : is this approach valid (i'm not sure about the reasonning at the end) and if yes how can we obtain the lift $g'$ ? If not how do we prove the result ?
In fact I am more generally interested in the following statement : a finitely presented $A$ module is projective if and only if there exist $f_1,...,f_n \in A$ with $f_1 + ... + f_n =1$ and $M_{f_i} \cong A_{f_i}^{n_i}$. A reference would be fine (great even).