Costa Rica is one of the safest countries in the world in regards to violent crimes. In fact USA Today ran a recent article on the Top 10 countries in the world for women travelers and Costa Rica made the list as one of the safest countries to visit.
Petty theft is a more common problem, though this is usually an opportunistic crime. Using a small amount of common sense can go a long way.
To minimize the risk of becoming a victim of a crime, do not do any of the following:
leave valuables anywhere but on your person or in your room safe
wear flashy jewelry or walk around by yourself with expensive cameras
flash large amounts of cash in any situation
become overly intoxicated with people you do not know
walk on the beach at night
walk through San Jose at night
carry a copy of your passport with you, leaving the original in your room or hotel safe
hitchhike or take rides from strangers
If you rent a car; always lock the doors, do not leave valuables in your car, park in secure areas with an attendant