David shows that he is a man after God's heart because he repents. He will not hide behind an unbelieving heart with outward shows of piety. He won't harumph himself up before others in self-righteousness. He calls out to God,
O Lord, open my lips,
and my mouth will declare your praise. - Psalm 51:15
And,
Have mercy on me, O God,
according to your steadfast love;
according to your abundant mercy
blot out my transgressions.
2 Wash me thoroughly from my iniquity,
and cleanse me from my sin! - Psalm 51:1-2
A man or woman after God's heart will delight in God's glorious grace. Reflecting God's love. Shown in Jesus. Granting us salvation. Capturing our hearts.