Over the years I've had people say something like this to me. "I just don't know why God let this happen to me." I, of course, always tried to be kind in my responses, but often I wanted to say, "Well... if you hadn't been out doing this or that then you wouldn't have gotten YOURSELF in this mess."
Don't hear me saying that any time you have troubles in your life it's because of sin - something you have done. The point I'm headed toward is that it's a lot easier to say, "Vindicate me, Lord, because I have lived with integrity and have trusted in the Lord without wavering." Than, "I know I really messed up, Lord, I promise I'll be good if you help me out of this one!"
This Psalm of David is an example of how we should strive to live life.
We see that David did what was right "lived with integrity, trusted in the Lord, live by God's truth"
and DIDN'T do what was wrong "sit with the worthless, associate with hypocrites)" (reminds you a little of Psalm 1 don't you think?)
and he spent time worshipping and telling of God's greatness "I wash my hands in innocence and go around Your altar, Lord, raising my voice in thanksgiving and telling about Your wonderful works."
Looks like a good plan. Why don't you see how you can put it into practice in your life?