1 Samuel 30:6-8

1 Samuel 30:6-8 (KJV)
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.
7 And David said to Abiathar the priest, Ahimelech’s son, I pray thee, bring me hither the ephod. And Abiathar brought thither the ephod to David.
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.

In Trials, Come To The Lord In Prayer

It was because David prayed, that he got the answer he needed from God. Therefore, the Lord’s wishes came to pass. This is when David and his six hundred men went and pursued after the Amalekites.