$\int_0^1 fg\geq 0$ for every non negative, continuous $g$ implies $f\geq 0$ a.e.
Solution 1:
Suppose that $A \subset (0,1)$ is measurable, is of positive measure and $f<0$ on $A$. The idea is that we want to construct a continuous function $g$ such that $$\int_0^1 fg\, dx<0. $$ A logical way to do this would be to choose $g$ such that $g\geqslant 0$ in $A$ and $g=0$ on $(0,1) \setminus A$. However, since $A$ is only a measurable set, in general $g$ will be discontinuous.
The way to get around this is to use the result I mentioned in the comments. A direct corollary of this result is that, given $\varepsilon >0$, there exists a (relatively) closed set $F \subset A$ such that $\vert A \setminus F \vert <\epsilon$. Choosing $\epsilon = \vert A \vert /2 >0$, we have that $$\vert F \vert=\vert A \vert - \vert A \setminus F\vert= \vert A \vert /2 >0.$$ Since $\vert F \vert >0$, the interior of $F$ is nonempty. Thus, there exists an open set $U$ compactly contained in the interior of $ F$ (just take a small ball for example). Define $g$ such that $g$ is continuous, nonnegative, $g=0$ in $A\setminus F$, and $g=1$ in $U$. Then \begin{align*} \int_0^1 fg \, dx &=\int_F fg \, dx \\ &=\int_U f \, dx + \int_{F\setminus U} fg \, dx \\ &\leqslant \int_U f \, dx \\&<0. \end{align*} This completes the proof.