This is one of my favorite tips and I also consider it a good practice.
How to close any java input or output Stream.
/** * Closes the specified stream. * * @param stream The stream to close. */ private static void closeStream(Closeable stream) { if (stream != null) { try { stream.close(); } catch (IOException e) { Log.e("IO", "Could not close stream", e); } }