How to print stacktrace for an exception Android

Somk picture Somk · Nov 21, 2011 · Viewed 45.7k times · Source

I want to print the stack trace because at the moment I have this running.

} catch (IOException e) {
    throw new Error("Copying Failed");
}

And I have been told to print e.stacktrace();

How do I do this?

Answer

Vit Khudenko picture Vit Khudenko · Nov 21, 2011
} catch (IOException e) {
    Log.e("YOUR_APP_LOG_TAG", "I got an error", e);
}

And check the LogCat for the output.