>> dont use std out and std error, use a proper logging system which
>> writes using the android logging functions
>
> Please suggest something that's portable to all the platforms on
> which I want to run this code.
Everything is portable with an intermediate interface. From a macro that
turns your logging function into a platform-specific one to a function
with platform-specific implementations, the options are many.
See http://en.wikipedia.org/wiki/Bridge_pattern, though the
implementation in this case can be pretty trivial (a single function
that you expose to your code that has multiple implementations).
Tim