In fact one can show the following in this situation:
If $R$ is a noetherian domain with a unique non-zero prime ideal $P$, then $R$ is a UFD if and only if $P$ is principal.
You have already shown the one direction, let me proof the other one, which is very easy: Since $R$ is a UFD, which is not a field, there is at least one irreducible element. This element generates a non-zero prime ideal, which of course coincides with $P$ by the uniqueness of $P$. Thus $P$ is principal.
With a little more work, it can be shown that any ideal of $R$ is principal in this case: If $I \neq 0$, we find a maximal $n$ with $I \subset P^n$. Take some $f \in I$ with $f \notin P^{n+1}$. Since $P^n/P^{n+1}$ is a one-dimensional vector space, we obtain that the residue class of $f$ generates it. Nakayama tells us that $f$ generates $P^n$, i.e. $I=P^n$ is indeed principal.