Tourist areas in the United States are generally safe, and the Cape and islands are safer than most. Although a number of towns, particularly the larger ones, suffer their share of crime (much of it drug- and alcohol-related), there's no such thing as a "bad neighborhood" here, per se. However, with crime on the increase everywhere, you need to stay alert and take the usual precautions. Avoid carrying valuables with you on the street or at the beach, and be discreet with expensive cameras and electronic equipment. When milling in crowds (in Hyannis or Provincetown, for example), place your billfold in an inside pocket, and hang on to your purse; anything kept in a backpack should be buried beyond reach. In closely packed places, such as restaurants, theaters, and ferries, keep your possessions in sight, and never sling a bag over the back of your chair: It's too easy a target. Alas, anything left visible in a car, locked or unlocked, is an open invitation, even in secluded Nantucket.
It would be rare in this region to find security staff screening all those who enter a hotel, especially if there's a restaurant on the premises, so don't relax your guard until your door is securely locked. Many areas are still so countrified that homeowners don't even lock their doors, and you'll find that most B&Bs are fairly laissez-faire; a few lack bedroom door locks altogether. If you're traveling light, it shouldn't matter, but if you're the cautious type, inquire about security measures before setting out.
Women, unfortunately, are no safer here than anywhere else, so avoid visiting deserted areas alone, even during the day. Hyannis can get a bit rowdy when its dance clubs are in full swing, and even more so when they let out. For the most part, though, this is a peaceful place, more like the 1950s, and as long as you keep your wits about you, you should be able to relax, relatively speaking.
Driving Safety -- Though Massachusetts is quite strict, drunk driving is a definite hazard: The police logs are full of offenses, from foolish to fatal. The best tactic is to avoid the offenders as much as possible, primarily by staying off the roads late at night. It's probably not a good idea to cover long distances at night, in any case, since there are no 24-hour gas stations to help out in case of emergency. In the event of a breakdown, drivers are usually advised to stay in the car with the doors locked until the police arrive. This is a small and friendly enough place, though, that it would probably be all right to take a chance on the kindness of strangers. Use your judgment, and err, if at all, on the side of caution.
Carjacking has yet to make an appearance on the Cape, but car theft runs high in Massachusetts as a whole, so lock your doors even if the natives never bother.