Legal and paperwork
The legal paperwork involved in buying property in China as a foreigner is far more complex than that of most Western countries. As an expat, you need to prove that you're legally working in China and have lived in China for more than 12 months.
It's customary to hire an agent to do most of the legwork of finding and securing an apartment. This makes the entire process a more personal affair, as you must find a trustworthy agent, and create good guanxi with him/her. Thankfully, these agents will also deal with the worst of the paperwork for you, but be prepared to pay for this help.
After finding an apartment you want to buy, you have to draft a contract and negotiate the price, payment schedule and all other relevant aspects of the purchase. Doing this without an agent is not recommended.
If the seller agrees, you'll be expected to pay a good-faith deposit, usually one percentage of the total price. After that's done, you need to notarize the contract and have it approved by the Chinese government.
Expect to pay several percentage of the total purchasing price in taxes when buying, registering and transferring the deed. Local government rules and regulations, if any, will apply.
The land-lease and land-use rights
You might have heard a rumor that the government owns all the land in China, and they merely lease it for 70 years at a time to citizens and businesses. In reality, it's actually all true! But it's also a lot more complicated than that. These regulations were first amended in the Chinese Constitution's Amendment Act of 1988, making the earliest expiration date of leased land somewhere in the late 2050s. As we're not there yet, no one can say for sure what will happen.
These land-use rights are expected to be renewed, and if you're worried about this, don't be. If the Chinese government decides that they need the land where your property is located for any reason, they can still evict you. If that happens, you will be compensated. However, if the land-use rights owner doesn't reapply for the land-lease one year before the expiration date, the government can take the land without compensating those using it.
In summation, you can own your home in China, but not the land it's built on. And it pays to keep up with your paper work.
When you sell
Selling an apartment in China is very much like buying one, but in reverse order, duh. As with the acquisition, everything is best handled by a reputable agent. Expect to pay transaction fees, land-use tax and a number of other minor costs as a seller.
If you want to transfer the money out of China, you may do so, granted you have proof that the money came from selling a property you own. You'll also need to have it approved by the State Administration of Foreign Exchange.
This is by no means a complete guide on buying property in China, and it would take months of studying to fully understand the legal and financial framework surrounding this topic. The truth is, if you're financially viable enough to buy property in China, chances are you'll also be able to hire someone to do the grunt work for you.