An asymptotic formula for the integral of the summatory function of $f(n)$ in short intervals is obtained, where $f(n)$ represents a certain divisor function. In particular $f(n)$ can be the characteristic function of the set of $k$-free or $k$-full numbers.