From there David went to Mizpah in Moab and said to the king of Moab, "Would you let my father and mother come and stay with you until I learn what God will do for me?"
So he left them with the king of Moab,1 and they stayed with him as long as David was in the stronghold.
References for 1 Samuel 22:4
But the prophet Gad2 said to David, "Do not stay in the stronghold. Go into the land of Judah." So David left and went to the forest of Hereth.3
References for 1 Samuel 22:5