I wanted to derive the equation,
$$\frac{\partial m}{\partial r}=4\pi r^2\rho(r),$$
using a different way than simply writing:
$$\rho(r)=\frac{dm}{4\pi r^2dr}.$$
I have decided to give it a try with the mass continuity equation:
$$\frac{\partial\rho(\vec r,t)}{\partial t}=\vec v\cdot\vec\nabla\rho(\vec r,t)+\rho(\vec r,t)\vec\nabla\cdot\vec v.$$
This my approach to dealing with it. Let's assume that the matter is incompressible, $\vec\nabla\cdot\vec v=0$, and that the density is time-independent, $\rho(\vec r,t)=\rho(\vec r)$. I consider a shell of the thickness $dr$ moving with a velocity along the shell's radius (in spherical coordinates $\vec v=(v_r,0,0)$). Hence the above equation reduces to
$$\vec v\cdot\vec\nabla\rho(\vec r)=0.$$
In the spherical coordinates, omitting all variables, it is given as follows
$$v_r\frac{\partial\rho}{\partial r}+v_\theta\frac{1}{r}\frac{\partial\rho}{\partial\theta}+v_\phi\frac{1}{r\sin\theta}\frac{\partial\rho}{\partial\phi}=0.$$
But because the velocity is along the radius we get
$$\frac{\partial\rho}{\partial r}=0 \ \Rightarrow \ \rho=const.$$
EDIT: After correcting the mistakes we arrive at the result indicating that the density is constant, which means that the object has to have a uniform mass distribution. This is not a result I wanted to get since I need a density to be radius-dependent. Is it the right approach to this problem or cannot the mass continuity equation be used to get the radial change of mass?