Which does God prefer most, giving to the church or giving to the poor?
(From an Evangelical, Sola Fide perspective)
The question is based on a false dichotomy. Neither is more pleasing to God.
Both types of giving are a sign of obedience to God, and an act of love and mercy if our motive in doing either is pure. If we are doing either simply to do so, or to "earn points" then neither is pleasing to God. If we're trying to earn points with God, then it isn't an act of love or charity, but rather one of selfishness.
Of course, love is the greatest commandment.
Matthew 22:36-40 (KJV) 36 Master, which is the great commandment in the law? 37 Jesus said unto him, Thou shalt love the Lord thy God with all thy heart, and with all thy soul, and with all thy mind. 38 This is the first and great commandment. 39 And the second is like unto it, Thou shalt love thy neighbour as thyself. 40 On these two commandments hang all the law and the prophets.
The verses supporting Sola Fide (Salvation by Faith Alone) are covered extensively elsewhere on the site, so I'm omitting them in the interest of brevity. Suffice it to say that the doctrine teaches that our "good works" don't get us to heaven, and are not, in and of themselves, pleasing to God. Isaiah 64:6 state that our righteousness is no more good than "filthy rags".
The giving a tithe or an offering can be compared the sacrifices brought to the Temple in Old Testament times.
Hosea 6:6 (KJV) For I desired mercy, and not sacrifice; and the knowledge of God more than burnt offerings.
In other words, it's the heart condition - the love that counts - what David calls the "Inner parts" in Psalm 51:6 (KJV)
Behold, thou desirest truth in the inward parts: and in the hidden part thou shalt make me to know wisdom.
Giving offerings is also an act of mercy (depending on what the Church actually does with the money.) In our Church, for example, there is a distinction between tithes and offerings.
- Tithes are the 10% of our income that we give to the Church, which is used to support the business of the Church - pay for the building, electricity, Hymnals, Bibles, and other mundane needs. These allow the Church to do its business - training up Christians, teaching us the principles of God, teaching us to love our neighbors, and equipping us to witness to others and see them get saved. The motivation for giving tithes should be two-fold. One reason is simply because God demands it, and we obey. The other is that we know that ultimately, the money all works directly or indirectly toward saving people from an eternity in Hell, and that's loving people.
- Offerings are over and above tithes. In our Church, they are all designated for different purposes: Supporting missionaries, helping those in need, etc. The pure motivation for giving is to give to those who need it more than us, again, out of love and mercy.
Of course, not everyone gives for the same reasons.
- There are, of course, those that think they can buy their way into heaven.
- There are those that give large sums of money to "look good" ("Oh, look at me, I'm a righteous person because I give so much money." Jesus rebuked this in His teachings, by the way.)
There are those that give to the poor for similar purposes. I don't believe that God honors this either. What is pleasing to God is...
and a whole host of other qualities that have to do with the condition of our hearts, and not our external actions. Where people get confused is that if we do have those traits, we will naturally give because we love, have mercy, are humble, etc. Those are the "fruits" that grow out of the seed of our love.
People have both physical and spiritual needs. If we gave our lives only to meeting people's physical needs and never did anything for people's spiritual needs, the impact could be to give them comfort here but risk them having an eternity without God.
However, if we gave our lives to only meeting people's spiritual needs, then many people would die of hunger before they could ever begin a relationship with God.
In reality, people are both physical and spiritual beings with both physical and spiritual needs. The Bible specifically commands us to help the poor with physical needs.
But if anyone has the world's goods and sees his brother in need, yet closes his heart against him, how does God's love abide in him? 1 John 3:17 ESV
Yet, the Great Commission Jesus gave to us all is to proclaim to the world how mankind may be reconciled to God, be forgiven of their sins, and enter into a relationship with God through faith in Jesus Christ.
"Go therefore and make disciples of all nations, baptizing them in[a] the name of the Father and of the Son and of the Holy Spirit" Matthew 28:19 ESV
Now, giving to churches SHOULD result in both of these, since the church should itself be involved in both the Great Commission and meeting the needs of the poor. Many churches, of course, don't do one or the other of these that well, so giving to the church can fulfill one or both of these, depending on the particular church.
So, the answer is a resounding "YES!" God commands us to do both--give to the poor and give so that people all over the world can hear and respond to Jesus. Doing only one of them, regardless of which one we may choose, is inappropriate.
As Isaiah 64:6 says:
All our righteousness is as filthy rags.
Put another way, even our good deeds in and of themselves do not curry favor with God. Any works we do are done as signs of the fact that we appreciate what God has done for us (John 14:12) and they are outflows of that appreciation. Our works do nothing except signify the transformation that has already occurred.
Thus, the question is not "What does God prefer?" but rather, "What makes the most sense.'
Practically speaking, Christians who give do so in order to alleviate suffering, because we know that God's desire is not that others suffer. We know from Matthew 25 that those who do more than just say "Lord, Lord," want to attend to the practical needs of their fellow man.
As such, the question is, how to best use that money to do so.
Two points are held in tension:
Churches as institutions have economies of scale that can more efficiently distribute aid. (Think Compassion International, Catholic Charities of America, the Salvation Army, etc...) 
Not all acts of relief require economies of scale, however, so sometimes direct aid can bypass administrative costs.
This is why Scripture tended to speak of "tithes and offerings" as separate categories.
Tithes were a levied tax in Ancient Israel to support the church, separate from the government. These tithes ensured there was a synagogoue in place that could, amongst its other activities, coordinate good works.
Offerings were free-will gifts (one could even call this "alms") above and beyond required "taxes" that could help in immediate cases.
Both categories were expected of all believers.
- Economies of Scale also allow institutions to respond to large crises (disasters, famine, endemic social issues) that individuals cannot. Implicit in scale is waste, fraud, and abuse (yes, Mr. Baker, I'm talking about you!), but the hope is that more often than not the economy of scale can outweigh the lapses.
Short, mildly off-the-cuff answer here:
If you look at the New Testament, most (all?) of the references to collecting/offering/giving money were related to the material needs of poor Christians - either locally, or further afield.
Noting also Paul's attitude to being paid for his ministry, I'd say that there isn't a great New Testament precedent for giving the majority of whatever you give to the church for the church.
Contributing to the needs of the church is a precept of the Catholic Church.
Alms giving is a corporal work of mercy.
It may vary parish to parish, but when you contribute to the offertory, you are helping the poor who come to be helped and healed by the local Church.
Many times there will be a special collection for missions or charities. Then you know you're giving will directly help the needy, by those who can help them best.
Any act of charity helps build up within you the virtue of charity, but the most difficult acts are the ones that help the most. Giving one dollar to your Church is not a difficult act, steadily increasing your giving as you have the means will make you more charitable. Giving one dollar to a homeless person is not a difficult act, buying them a coat (or giving them your own is)
God must want us to increase in virtue, so whatever acts make us increase the most align us best on the path to seek the will of God.
We are commanded to do both.
Luke 14:12-14 Then He also said to him who invited Him, “When you give a dinner or a supper, do not ask your friends, your brothers, your relatives, nor rich neighbors, lest they also invite you back, and you be repaid. But when you give a feast, invite the poor, the maimed, the lame, the blind. And you will be blessed, because they cannot repay you; for you shall be repaid at the resurrection of the just.”
i.e. we should give to help the poor with no thought of reward.
Matthew 26:6 And when Jesus was in Bethany at the house of Simon the leper, a woman came to Him having an alabaster flask of very costly fragrant oil, and she poured it on His head as He sat at the table. 8 But when His disciples saw it, they were indignant, saying, “Why this waste? For this fragrant oil might have been sold for much and given to the poor.” But when Jesus was aware of it, He said to them, “Why do you trouble the woman? For she has done a good work for Me.For you have the poor with you always, but Me you do not have always.
i.e. we should give to glorify Christ.
To anyone who says that building a great cathedral or monument to God when the money could be spent on the poor, see the above verse.
Which is "more pleasing"? I don't know. Would God prefer that you help a widow or an orphan, or that you help a homeless person or a sick person? I'd say do all you can and don't worry about what's worth the most points.
Dittos to those pointing out that salvation is by faith and not works. I won't repeat that.