Could someone please explain to me why the this answer solves this problem
I'd comment on the original question and answer, but I don't have enough rep to do that.
thanks.
An elementary argument based on the inner and outer regularity of the Lebesgue measure shows that every Lebesgue measurable set can be written as the union of a $G_\delta$ set and a set of measure zero. The argument there thus shows that $\int_E gdm = 0$ for any Lebesgue measurable set E. Now suppose that $g \neq 0$ on a set of positive measure. It would then follow that either $g>0$ or $g<0$ on a set of positive measure. Consider the former case: if $m(\{g>0\})>0$ then since $\{g>0\}=\cup_n \{g>\frac{1}{n}\}$ by the continuity of measure it must be the case that $m(\{g>\frac{1}{n}\})>0$ for some n. For this n, consider $0=\int_{\{g>\frac{1}{n}\}} g dm > \frac{1}{n} m(\{g>\frac{1}{n}\})$ a contradiction
By the way, there is a much cleaner proof than that one. The Lebesgue Differentiation Theorem says that at every Lebesgue point (which is a.e.) we have $g(x)$ = $\lim_{r\to 0}\frac{1}{2r} \int_{x-r}^{x+r} g(t)dt$. Taking limits with rational endpoints gives that $g(x)=0$ at all Lebesgue points because all of the integrals are zero.
Define $F(x) = \int_0^x f(t)\,dt.$ The function $F$ is continuous and zero at every rational. Therefore $F(x) = 0$, $0\le x \le 1.$