Unclosed closable

Context

Implementation

Affects

Memory Efficiency

Problem

An object implementing the java.io.Closeable is not closed

Refactorings

Close Closable

Resolves

Memory Efficiency

Affects

Solution

The object should be closed properly with

import java.io.Closable

Closable object = ...

// do anything with object

object.close();
Note

Currently Android only supports Java 6. But if it will support Java 7 one can also use the java.lang.AutoCloseable interface in conjunction with the try-with-ressources statement:

try (AutoCloseable object = ...) {
   object.doStuff();
}

Links

Related