Source:
<code>public boolean writeTranslationUpdates(List<TranslationItem> updates) { boolean result = true; db.beginTransaction(); try { for (int i = 0, updatesSize = updates.size(); i < updatesSize; i++) { TranslationItem item = updates.get(i); if (item.exists()) { int displayOrder = 0; final Translation translation = item.getTranslation(); if (item.getDisplayOrder() > -1) { displayOrder = item.getDisplayOrder(); } else { <START> Cursor cursor = db.query( <END> TranslationsTable.TABLE_NAME, new String[] {TranslationsTable.DISPLAY_ORDER}, null, null, null, null, TranslationsTable.DISPLAY_ORDER + " DESC", "1" ); if (cursor != null && cursor.moveToNext()) { displayOrder = cursor.getInt(0) + 1; } } ContentValues values = new ContentValues(); values.put(TranslationsTable.ID, translation.getId()); values.put(TranslationsTable.NAME, translation.getDisplayName()); values.put(TranslationsTable.TRANSLATOR, translation.getTranslator()); values.put(TranslationsTable.TRANSLATOR_FOREIGN, translation.getTranslatorNameLocalized()); values.put(TranslationsTable.FILENAME, translation.getFileName()); values.put(TranslationsTable.URL, translation.getFileUrl()); values.put(TranslationsTable.LANGUAGE_CODE, translation.getLanguageCode()); values.put(TranslationsTable.VERSION, item.getLocalVersion()); values.put(TranslationsTable.MINIMUM_REQUIRED_VERSION, translation.getMinimumVersion()); values.put(TranslationsTable.DISPLAY_ORDER, displayOrder); db.replace(TranslationsTable.TABLE_NAME, null, values); } else { db.delete(TranslationsTable.TABLE_NAME, TranslationsTable.ID + " = " + item.getTranslation().getId(), null); } } db.setTransactionSuccessful(); this.lastWriteTime = System.currentTimeMillis(); this.cachedTranslations = null; } catch (Exception e) { result = false; Timber.d(e, "error writing translation updates"); } finally { db.endTransaction(); } return result; }</code><technical_language>Please, consider closing this cursor</technical_language>

Target:
public boolean writeTranslationUpdates(List<TranslationItem> updates) { boolean result = true; db.beginTransaction(); try { for (int i = 0, updatesSize = updates.size(); i < updatesSize; i++) { TranslationItem item = updates.get(i); if (item.exists()) { int displayOrder = 0; final Translation translation = item.getTranslation(); if (item.getDisplayOrder() > -1) { displayOrder = item.getDisplayOrder(); } else { Cursor cursor = db.query( TranslationsTable.TABLE_NAME, new String[] {TranslationsTable.DISPLAY_ORDER}, null, null, null, null, TranslationsTable.DISPLAY_ORDER + " DESC", "1" ); try { if (cursor != null && cursor.moveToFirst()) { displayOrder = cursor.getInt(0) + 1; } } finally { if (cursor !=null) cursor.close(); } } ContentValues values = new ContentValues(); values.put(TranslationsTable.ID, translation.getId()); values.put(TranslationsTable.NAME, translation.getDisplayName()); values.put(TranslationsTable.TRANSLATOR, translation.getTranslator()); values.put(TranslationsTable.TRANSLATOR_FOREIGN, translation.getTranslatorNameLocalized()); values.put(TranslationsTable.FILENAME, translation.getFileName()); values.put(TranslationsTable.URL, translation.getFileUrl()); values.put(TranslationsTable.LANGUAGE_CODE, translation.getLanguageCode()); values.put(TranslationsTable.VERSION, item.getLocalVersion()); values.put(TranslationsTable.MINIMUM_REQUIRED_VERSION, translation.getMinimumVersion()); values.put(TranslationsTable.DISPLAY_ORDER, displayOrder); db.replace(TranslationsTable.TABLE_NAME, null, values); } else { db.delete(TranslationsTable.TABLE_NAME, TranslationsTable.ID + " = " + item.getTranslation().getId(), null); } } db.setTransactionSuccessful(); this.lastWriteTime = System.currentTimeMillis(); this.cachedTranslations = null; } catch (Exception e) { result = false; Timber.d(e, "error writing translation updates"); } finally { db.endTransaction(); } return result; }