Psalms 51:10-12 Create in me a clean heart, O God; and renew a right spirit within me. Cast me not away from thy presence; and take not thy holy spirit from me. Restore unto me the joy of thy salvation; and uphold me with thy free spirit.
David is called a "man after God's own heart." Considering that he lusted after his neighbor's wife, committed adultery with her, and had her husband murdered, the Lord's description of him is remarkable. How could a man who was convicted a murderer and an adulterer also be called one after God's own heart?
The answer is simple but profound: God did not regard David according to the actions of his sinful nature, but according to the deepest motivations and disposition of his heart and will; and these were revealed by David's response to the conviction which Nathan the prophet brought upon him; a conviction which brought immediate total confession and repentance, and a broken and contrite heart. This response exemplified the shepherd king's walk with God throughout the entire journey of his life .
If, after David had fallen he made excuses, rationalized, or resisted the clear message of his sinfulness it would have been a totally different story. His heart would have revealed a self-justifying, self-righteous attitude with no realization of his absolute need for God's mercy. This would have defeated and defined him as a man after his own heart. But the immediacy and completeness of David's confession qualified him for the Lord's forgiveness and mercy, saving him from death and restoring him to that most treasured relationship of his life, his relationship with YHVH.
The consequences of his sin were very serious and followed David all the days of his life. But he demonstrated the genuineness of his repentance by never railing against God for the troubles which followed him as a consequence of his sin with Batsheva. David always rose up, submitted, and humbly praised God, writing wonderful psalms and pouring out his heart before the Lord. He served God and worshiped Him all his life. So the Lord God didn't reckon David's life by his fall -- but by his walk, and by his heart.
We all stumble in many ways, but God does not define us by our failures. It's our love for Him and our honesty before Him that reveals a true walk of faith! So if you fell, you messed up, your sin got the best of you, then come clean. Make your confession. Accept the consequences without complaining, allow the Lord to forgive and restore you completely, and continue on your journey with Him. That was David's heart. His example is worthy to follow. May you also be one of those that lived their life "after God's own heart!"