A desire for godliness in the midst of an ungodly people.
v1-2: David's integrity, a desire to lead a blameless life, having trust in God. This is not a claim to perfection, but a willingness to be tested by God. Contrast Michal's words in 2 Sam 6.20-23. We should not pray these words lightly for ourselves.
v3: A heart set on obedience, whilst fully dependent on God.
v4-5: Avoid bad company; the man who wants to be godly cannot share fellowship with the ungodly. Such people will not promote spiritual growth. We do not just avoid such sins, but we avoid close company with those who persist in them.
v6-8: Desire for the very presence of God. It is not enough to avoid the fellowship of the ungodly, we must seek the presence of God; "your altar, O Lord,...the house where you live, O Lord, the place where your glory dwells."
v9-10: As in v4-5, avoiding the ways of the ungodly. We are confident that God makes a distinction between the godly and the ungodly.
v11-12: Walk in integrity, Ps 25.21; a desire for God's presence must accompany a godly walk.