Short answer, don't do it.
Long answer - not that straightforward. In Zagreb, Croatia, for example, cycling infrastructure is rare (about 100km of streets have any kind of cycling infrastructure in a city of 900.00 people) and really low quality. Main city avenues typically have at best a single-direction cycling path on the footway/pavement and cyclists often use these paths in the opposite direction, e.g. to avoid having to cross an avenue twice just to travel a kilometre down the side they're already on.
While such cyclists have to enter crossroads carefully (i.e. at pedestrian speeds) because cars don't expect cyclists from the opposite direction (although they often don't seem to expect them from any direction...), this practice of driving in the opposite direction on a cycling path is typically not at all dangerous because most such footways see little pedestrian traffic so the offending cyclist temporarily moves off of the cycling path when someone in the right direction approaches.
Riding in the opposite direction is of course illegal, but I personally don't mind when I see such a cyclist approaching because they typically move out of the way and because bicycle traffic is ignored by local planners to such an absurd degree that I'd much rather see people cycle illegally as long as it's safe, than not cycle at all.
That said, doing this in a cycling lane is typically much more dangerous and should as a rule be avoided, for a number of reasons people highlighted in other answers.