I visited David a few years ago as a solo and it didn't feel any different in terms of safety to any other towns in the area - there wasn't anything particularly attractive about it though (although I was only there for a stop over and it was a few years ago... I'm sure someone will soon pipe up if its improved of late!)
You said you'd booked your flight to Panama City already, right? If so, I would definitely recommend spending a few days there if you have time - at least to see the canal and to marvel at the contrast between the Old Town and the modern city - such a contrast and really fascinating! From there you can either bus to Almirante and then boat to Bocas or bus to David, overnight there and continue the next day.
If you haven't booked your flight yet, and are not particularly attracted to Panama City itself, then did you know you can fly straight from San Jose to Bocas with www.natureair.com? OR if you like your Caribbean beach towns, you could interbus from San Jose (www.interbusonline.com) to Puerto Viejo on the Costa Rican Caribbean coast not far from the border. Enjoy a few days there and then take a shuttle across the border to Bocas - this border crossing is interesting too! Both journeys can't be more than 4 hours if my memory serves me correctly.