Psalm 26 is identified with only “By David” and is part of the collection of Psalms 25-28 which focus on God as David’s protector. David had three specific requests for God and several reasons for why he believed God would honor his requests.
First, David wanted God to “vindicate” him (Psalm 26:1). He asked God to judge him and find him not guilty, because of his “integrity” and because he trusted God “without wavering.”
Second, David asked God to “examine…and test…[and] evaluate” him (Psalm 26:3-8). He was confident that when God looked deep into his mind and heart, God would find a man who 1) meditated on God’s faithfulness, 2) was motivated by God’s loyalty, 3) did not “associate with deceitful men,” and 4) maintained “a pure lifestyle.” The last one was especially important, because a person had to be clean to approach God in the Tabernacle, and David loved to meet with God there.
Third, David asked that he not get swept away with sinners in God’s judgment (Psalm 26:9-12). These included people who were “always ready to do wrong or offer a bribe.” Instead, he reiterated his claim of “integrity” and knew that he would remain “safe,” allowed to continue “among the worshipers” of Jehovah.
Although we do not have to worry about God accidentally judging Christians alongside sinners, and we do not have to worry about our salvation slipping away because of sin, it is a joy to be able to praise God with a clean heart and conscience when we intentionally obey him and spend time with others who do as well.