David was a man after God’s own heart. God let him rise to stardom so to speak, and he let him fall into deep sin; yet He knew the depth of David’s desires and supplications and let him rise out of sin into kingship. God knew the depth of David's love for Him. David being a man not ashamed to call upon the Lord in pitiful measures; was sought deliverance in the only one who could give it.
Psalms 25: 4 -5
Enjoy, and God Bless,