Commit cafecd1d authored by Grant Patterson's avatar Grant Patterson

Closing more cursors

parent 5a43b38f
......@@ -103,29 +103,39 @@ public class ArtefactDataSQLHelper extends SQLiteOpenHelper {
}
public void uploadAllSavedArtefacts() {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(ArtefactDataSQLHelper.TABLE, null, null, null, null,
null, null);
if ( VERBOSE ) Log.v(TAG, "uploadAllSavedArtefacts: returned " + cursor.getCount() + " records.");
while (cursor.moveToNext()) {
Artefact a = createArtefactFromCursor(cursor);
a.upload(true, mContext);
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(ArtefactDataSQLHelper.TABLE, null, null, null, null, null, null);
try {
if (VERBOSE) Log.v(TAG, "uploadAllSavedArtefacts: returned " + cursor.getCount() + " records.");
while (cursor.moveToNext()) {
Artefact a = createArtefactFromCursor(cursor);
a.upload(true, mContext);
}
} finally {
cursor.close();
}
}
public Artefact loadSavedArtefact(Long id) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(ArtefactDataSQLHelper.TABLE, null, BaseColumns._ID + " = ?", new String[] { id.toString() },
null, null, null);
if ( cursor == null )
return null;
cursor.moveToFirst();
return createArtefactFromCursor(cursor);
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(ArtefactDataSQLHelper.TABLE, null, BaseColumns._ID + " = ?",
new String[] { id.toString() }, null, null, null);
try {
if (cursor == null)
return null;
cursor.moveToFirst();
return createArtefactFromCursor(cursor);
} finally {
cursor.close();
}
}
public Artefact[] loadSavedArtefacts() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment