In the Psalms David constantly praised the Lord. Consider making praising the Lord a constant habit, it leads toward joy. The more joy you have, the more you will resist bad stuff because now you don’t want to lose your joy.
David had great confidence in his God. He had a huge belief that God’s ways were best (Obviously with a couple of massive slip-ups that caused massive destruction). Consider praying:
“Father, help me to trust Your ways and Your laws. I do believe that they are best, help me to improve.”
David had a proper “Fear of God.” When he lived that way great things happened. When he lost his fear and sinned, bad (Really bad) things happened. David wrote:
“Psalm 2:11 ESV Serve the Lord with fear, and rejoice with trembling.”
Other chapters say that we should strive to increase our fear of the Lord. Why? When David feared the Lord, life was great. When he didn’t…
Proverbs 28:14 ESV Blessed is the one who fears the Lord always, but whoever hardens his heart will fall into calamity.” Consider praying:
“Father, show me why fearing You is wisdom.”
Finally, these are two killer habits for bad habits. Consider striving to make them your habits.