David had incredible confidence in the Lord, and because of that, he was able to do some incredible things and get through some incredibly difficult times. His confidence came from a cycle where he would: declare "God is MY God", call out to Him when he needed help, trust that He would act on his behalf, and believe that God delighted in him.