The urge from Psalm 139 might be to do what many already do—go into prayer with the expectation that God is going to give you an answer in prayer that very moment. So we have people saying "I'll pray about it" or "let me pray about it" in response to all sorts of things. At first glance that might seem to be what David is doing.

First of all, David does more than go to God and say, "God can you give me an answer about _____ ". The majority of his time is spent praising God for his omniscience and omnipresence. Does that precede your requests?

Second, David doesn't exactly say how he expects to hear from God. In Psalm 139 David merely comes and prays for God to search him and know his heart.

Also, David is not asking God to reveal what is morally right or wrong. He is not using God like an ethical Eight Ball. David already knows that he should not have partnership with those who hate God. He is asking God about himself. "God, I know what is right....I'm asking you to reveal if I am in the right."

But many people get caught up in prayer, and sometimes bored or burned out, because they think God is supposed to be talking verbally in real time. When he doesn't? “Well, he isn't there, doesn't care, or simply hasn't the time." Often I think we may even come to doubt his existence.

But should we expect that? Should we expect to pray our own personal Psalm 139 and have God give us a special revelation right then and there? Does God’s word (God’s revelation to us) lead us to expect that? It certainly leads us to believe God can. But we aren’t really given a picture where every Christian has a telephone line to God and we can have conversations together. God is more of texter, you might say. 

Graham Goldsworthy is noted in an article on prayer for clarifying, “Every case of special guidance given to individuals in the Bible has to do with that person's place in the outworking of God's saving purposes.” In other words, Goldsworthy is saying that if we follow the grand narrative of scripture, leading to and from Christ, revelation comes to keep that going. He adds, “There are no instances in the Bible in which God gives special and specific guidance to the ordinary believing Israelite or Christian in the details of their personal existence.” That is a strong statement.

Is prayer where we should hear from God? Consider this short clip from John Piper on What is Prayer? (its only 5 minutes long)

That said, how do we hear from God? If there are any grievous ways in us, how will God make it known to us? A few things to consider.

Through Others

Recall when David committed adultery with Bathsheba (2 Samuel 11-12). David was going along with life as if he had gotten away with murder. But then Nathan comes. The prophet comes and speaks to David revealing his sin to him. David learned about his sin through a messenger of God.

Through Church Members

Biblical community in the church is to be fundamentally a speaking-the-truth-in-love community. The church is there to help us grow in righteousness and avoid sin by directing one another towards wise choices and sound doctrine (Matthew 18:15-21, Ephesians 4:11-16, Galatians 6:1-5). Do not believe that if you go to other church members or your Lifegroup that you are avoiding going to God. True, church members might not always speak the word of God or know what to say. But if they do, and when they do, it is no less authoritative than when you read it yourself. Pride, not doctrine of prayer or revelation, most often keep us from hearing God’s wisdom from one another.

Through Your Pastor

If your pastor is walking with God and is a qualified pastor he wants you to come to him for counsel. He is not a genie or a Bible quiz champion. Rather, he is called and gifted by God to be a shepherd. A pastor’s heart is this—that you hear God’s word and recognize it for what it is (1 Thess 2:13). Pastor’s are primarily messengers, expositors, preachers, and teachers of God’s word.

Through the The Word of God

David’s whole plan for discovering sin and avoiding sin was not “I’ll pray about it”. Hardly! David’s plan to avoid sin and hear from God is centered on God’s law (his word and revelation). Consider these Psalms and how they relate to Psalm 139.
Psalm 119:11 — I have stored up your word in my heart, that I might not sin against you.
Psalm 119:119 — All the wicked of the earth you discard like dross, therefore I love your testimonies.
Psalm 119:9 — How can a young man keep his way pure? By guarding it according to your word.

It is not pious to avoid God’s word in the Bible and then go to God and say, “God say something”. David knows he hears first from God by his word.

Jesus is the Way, the Truth, and the Life

Jesus is himself the word of God incarnate. He is the “word became flesh”. Anyone who has ever been to VBS has learned that Jesus said, “I am the way, the truth, and the life” (John 14:6). But that means, then, that we should look to him as our way, our truth, and our life. God has revealed himself (his will, his ways, his character, etc) in Christ. Look to Christ and you may find what many did in the New Testament. We aren’t even asking the right questions to begin with! Christians are not wandering through the universe hoping God might give us a few tips here and there. We are being conformed be like another person—Jesus (Romans 8:29). Our Psalm 139 prayer is, "See if there is any unchristlike way in me." 

Making Decisions

Generally, the Bible doesn’t point us to pray to God as if prayer is the first responder in every circumstance. We make daily decisions on the spot. We ought to be taking into those decisions hearts filled with knowledge of God’s will. God’s word will lighten the way that we should go. David said that, “Your word is a lamp unto my feet and a light unto my path” (Psalm 119:105).

The Holy Spirit Will Guide Me

Like prayer, people blame all sorts of things on the Holy Spirit. “I just felt the Spirit leading me”. Based on the way some people talk about the Spirit and the decisions the come to, it may as well be the tooth fairy they are hearing. But the Spirit is not the wind beneath our wings, so to speak. The Spirit has inspired Scripture. The Spirit of God has led us and is leading us to God’s word in the Bible. Yes, the Spirit gives impressions and can lead us in the moment. But can you honestly say, “I prayed and the Spirit of God by which Jesus rose from the dead lead me to ______ .” If so, it will align with the Spirit inspired Scripture. Most often, the Spirit is leading us and empowering us to understand and obey the Bible.

Searching for Sin

So, in asking God to reveal if there is any sin in our lives, as David does in Psalm 139, we ought to consider how we might expect to hear from God. God has already given us everything we need (Ehp 1:3-4, 2 Tim 3:16-17). You might think, “well that all does not sound very practical or personal.” Wrong again. God’s word is active and living. It is not neutral. God’s word is not static or plastic or only ink on a page. Hebrews 4 says it does exactly what David needed in Psalm 139. “God, see if there is any grievous way in me”, David prayed. God does just that through his word. Read carefully Hebrews 4:12:

For the word of God is living and active, sharper than any two-edged sword, piercing to the division of soul and of spirit, of joints and of marrow, and discerning the thoughts and intentions of the heart.

What was the last part? It discerns the thoughts and intentions of our hearts. It gets deep in us and discerns. Isn’t that was David was praying for?

Before we get too disillusioned or set unbiblical expectations about God speaking in prayer, we must ask ourselves if Psalm 119:97 describes us. We are no more eager to hear from God in prayer than we can say, “Oh how I love your law”.

To pray like Psalm 139 we must do so with our Bible's open.