Vector potential of wavefunction in ring geometry Assume that we have a wavefunction on ring geometry of length L with solenoid inside (like the aharonov bohm experiment). We can change the magentic field $B$ inside the solenoid continuously just increasing the current.
Also assume that we have just solved the schrodinger equation for $B=0$ case, so we know wavefunction $\psi(x)$. Since this is ring geometry, this wavefunction satisfies the boundary condition
$$ \psi(x) = \psi(x+L) $$ 
where L is the perimeter of the ring. 
Now, we increase B, so the hamiltonian of this system includes vector potential $A$. When we include vector potential in our hamiltonian, we can easily get the wavefunction by just multiplying a phase factor to wavefunction for $A=0$, as following
$$ \psi(x) \rightarrow e^{i\frac{q}{\hbar} \int {A \dot{} dx }} \psi(x) $$
But since we have ring geometry, we require this wavefunction also satisfies the periodic boundary condition
$$  \psi(0) = e^{i\frac{q}{\hbar} \int_0^L {A \dot{} dx }} \psi(L) = e^{i\frac{q}{\hbar} {A L }} \psi(0) $$
and if $\psi(0) \neq 0$, we need 
$$ A = n\frac{\hbar2\pi}{qL}$$
where n is an integer.
But this means that the vector potential A, so magnetic field must be quantized. But as I mentioned earlier, solenoid can have continuous magnetic field. So I arrive at a contraction here. What is wrong in this argument?
 A: There is nothing wrong with your argument. If you have a geometry where there is truly no magnetic field where the ring is, then the flux through the ring is an integer multiple of the magnetic flux quantum. If you try to make the flux non-integer, the ring geometry will create a screening current that either adds or subtracts to the flux in such a way that the total flux is still an integer multiple. 
A real-world example of such a geometry is a superconducting loop, and a real-world application is the precise measurement of magnetic fields by SQUIDs.
A: The magnetic flux in the situation you are considering is only quantized when the system is a superconductor, and it is quantized for energetic reasons. The parallel transport formula for $\psi(x)$ that you wrote down is appropriate for some quantum particle moving around in time, and the fact that you get a nontrivial phase from $\exp(iq\int A)$ is just the statement that the flux produces an interference effect. If the flux was actually quantized, there would be no interference in an AB interference experiment!
The parallel transport formula for $\psi(x)$ is slightly misleading when $\psi(x)$ is a quantum field, rather than the wavefunction of a single particle. In the context of the AB effect, the phase of the quantum field $\psi(x)$ is not determined by computing $\exp(iq\int A)$, since otherwise $\psi(x)$ would be multivalued in the presence of a generic magnetic field, as you say. Note that the condition for the phase of $\psi(x)$ to be determined by this parallel transport procedure is exactly the statement that the gauge covariant derivative $D_A\psi(x)$ vanish (solve the differential equation $D_A\psi(x)=0$ to see this). The statement that $D_A\psi(x)=0$ is equivalent to saying that the kinetic term for $\psi$ in the action is minimized. Thus the question of whether flux is quantized is an energetic one. For a superconductor, the macroscopic-ness of the superconducting wavefunction means that we need to minimize the $|D_A\psi|^2$ term (here $\psi$ is the order parameter), which means that $D_A\psi=0$, which in turn means that the parallel transport equation holds, implying that flux is quantized by the single-valuedness of $\psi$. In a normal material though, flux certainly is not quantized: in e.g. an AB effect setup, it will be energetically favorable to have a non-quantized amount of flux, at the expense of having a non-minimized kinetic term for $\psi$. 
