Sep 11, 2008

(Android) How to resolve the exception of "Table has not been deactivated or closed"

I'm working on the migration my project from M5 to 0.9, i got some exceptions of SQLite which shows "Table/Cursor has not been deactivated or closed" in my database class, i found the problems come from the Cursor. After read the API documents, i understand each opened Cursor should be deactivated and closed after reading its content. Here is an example:

Cursor cursor = sqlite.query(table, null, selection, null, null, null, null);
if (cursor.getCount() > 0){
int cursorCount = cursor.getCount();
ArrayList records = new ArrayList();
cursor.moveToFirst();
for (int i=0; i record = new HashMap();
String[] columns = cursor.getColumnNames();
int columnsNb = columns.length;
for (int column=0; column

No comments: