24 The source of this distinction lies in the following words: For the Lord knows the way of the righteous, but the way of the ungodly shall perish. Sinners do not come near the counsel of the righteous for this reason, that the Lord knows the way of the righteous. Now He knows, not by an advance from ignorance to knowledge, but because He condescends to know. For there is no play of human emotions in God that He should know or not know anything. The blessed Apostle Paul declared how we were known of God when he said: If any man among you is a prophet or spiritual, let him take knowledge of the things which I write unto you, that they are of the Lord: but if any man does not know, he is not known.
Thus he shows that those are known of God who know the things of God: they are to come to be known when they know, that is, when they attain to the honour of being known through the merit of their known godliness, in order that the knowledge may be seen to be a growth on the part of him who is known, and not a growth on the part of one who knows not.
Now God shows clearly in the cases of Adam and Abraham that He does not know sinners, but does know believers. For it was said to Adam when he had sinned: Adam, where are you ? Not because God knew not that the man whom He still had in the garden was there still, but to show, by his being asked where he was, that he was unworthy of God's knowledge by the fact of having sinned. But Abraham, after being for a long time unknown— the word of God came to him when he was seventy years of age— was, upon his proving himself faithful to the Lord, admitted to intimacy with God by the following act of high condescension: Now I know that you fear the Lord your God, and for My sake you have not spared your dearly loved son.
God certainly was not ignorant of the faith of Abraham, which He had already reckoned to him for righteousness when he believed about the birth of Isaac: but now because he had given a signal instance of his fear in offering his son, he is at last known, approved, rendered worthy of being not unknown. It is in this way then that God both knows and knows not— Adam the sinner is not known, and Abraham the faithful is known, is worthy, that is, of being known by God Who surely knows all things. The way of the righteous, therefore, who are not to be judged is known by God: and this is why sinners, who are to be judged, are set far from their counsel; while the ungodly shall not rise again to judgment, because their way has perished, and they have already been judged by Him Who said: The Father judges no man, but has given all judgment unto the Son, our Lord Jesus Christ, Who is blessed for ever and ever. Amen.
Source: Homilies on the Psalms (New Advent)