"David was greatly distressed, for the men spoke of stoning him because the souls of them all were bitterly grieved, each man for his sons and daughters. But David encouraged and strengthened himself in the Lord his God.” - 1 Samuel 30:6
The calamity David was in now came about because he had been acting according to his own will and council rather than the Lords. Here, David had gone on his own, without the Lord's leading, and was off the narrow way. He was plotting and scheming like an unbeliever. He was no longer trusting in God in spite of all the Lord had done for him, blessed him with, and delivered him from throughout his life.