1 Samuel 22:1-2 NIV David left Gath and escaped to the cave of Adullam. When his brothers and his father’s household heard about it, they went down to him there. All those who were in distress or in debt or discontented gathered around him, and he became their commander. About four hundred men were with him.
1 Samuel 23:26-29 NIV Saul was going along one side of the mountain, and David and his men were on the other side, hurrying to get away from Saul. As Saul and his forces were closing in on David and his men to capture them, a messenger came to Saul, saying, “Come quickly! The Philistines are raiding the land.” Then Saul broke off his pursuit of David and went to meet the Philistines. That is why they call this place Sela Hammahlekoth. And David went up from there and lived in the strongholds of En Gedi.
What is important is that David, the great mighty soldier, who had killed Goliath and slain his ten thousands was disgraced and distress.
1 Samuel 18:6-9 NIV When the men were returning home after David had killed the Philistine, the women came out from all the towns of Israel to meet King Saul with singing and dancing, with joyful songs and with timbrels and lyres. As they danced, they sang: “Saul has slain his thousands, and David his tens of thousands.” Saul was very angry; this refrain displeased him greatly. “They have credited David with tens of thousands,” he thought, “but me with only thousands. What more can he get but the kingdom?” And from that time on Saul kept a close eye on David.
He feared for his life as he was being pursued all over Israel by Saul. Although surrounded by his family and about four hundred men he felt alone. He only refuge was God and he was praying that God deliver him from his enemies. He was convinced that God would deliver him and promised that he would give Him all the praise for that deliverance.
Psalm 142 teaches us how to pray when we feel trapped and alone, with no apparent way of escape from overwhelming circumstances.
Psalm 142:1-7 NIV I cry aloud to the Lord ; I lift up my voice to the Lord for mercy. I pour out before him my complaint; before him I tell my trouble. When my spirit grows faint within me, it is you who watch over my way. In the path where I walk people have hidden a snare for me. Look and see, there is no one at my right hand; no one is concerned for me. I have no refuge; no one cares for my life. I cry to you, Lord ; I say, “You are my refuge, my portion in the land of the living.” Listen to my cry, for I am in desperate need; rescue me from those who pursue me, for they are too strong for me. Set me free from my prison, that I may praise your name. Then the righteous will gather about me because of your goodness to me.