3 So David and his men came to the city, and, behold, it was burned with fire; and their wives, and their sons, and their daughters, were taken captives.
4 Then David and the people that were with him lifted up their voice and wept, until they had no more power to weep.
5 And David’s two wives were taken captives, Ahinoam the Jezreelitess, and Abigail the wife of Nabal the Carmelite.
6 And David was greatly distressed; for the people spake of stoning him, because the soul of all the people was grieved, every man for his sons and for his daughters: but David encouraged himself in the Lord his God.
-1 Samuel 30:3-6
I love how this shows that David is human, that he wept as the people did (as a point of clarification, this was before David became the king). Then when the people turned their anger and frustration toward them, David did not continue to feel sorry for himself and he did not turn back to them in anger. Rather, David, trusted or "encouraged himself" in the Lord. It is human to feel sadness for a time when things don't go well. However, it is how we continue on that matters. David continued by trusting in the Lord! In fact, he prayed to God and received an answer as to what he should do.
8 And David enquired at the Lord, saying, Shall I pursue after this troop? shall I overtake them? And he answered him, Pursue: for thou shalt surely overtake them, and without fail recover all.Then David did his part, he did as instructed. He pursued Amalekites, overtook them, and recovered everything they had taken.
-1 Samuel 30:8
This story in 1 Samuel also led me to a Psalm of David that encapsulates his trust in God.
3 What time I am afraid, I will trust in thee.It pleases my soul to know and to be continually reminded that when I put my trust in the Lord, he will fight my battles.
4 In God I will praise his word, in God I have put my trust; I will not fear what flesh can do unto me.