I think the solution to this question somehow involves Riesz Representation Theorem, but I don't see how to apply it.
Suppose $g$ is a measurable function on $[0,1]$ such that $\int_0^1 fg~dx$ exists for all $f\in L^2[0,1]$. Then $g\in L^2[0,1]$.
How do I use the above mentioned theorem to show it.