jeudi 19 mars 2015

How to close Cursor in getContentResolver for update method on android

Hi in my project I'm updating the database in for loop using the getContentResolver method. This is the coding I'm using for update the database



for(VOShoplyRetailer retailer:retailerMasterList){
ContentValues retailerCV = retailer.parseToContentValues();
int affectedRows = context.getContentResolver().update(DataContract.RetailerMasterEntry.RETAILER_MASTER_CONTENT_URI,
retailerCV,
DataContract.RetailerMasterEntry.COLUMN_RETAILER_ID+" = ?",
new String[]{retailer.getRetailerId()}
);
}


and I'm getting error as


03-20 11:55:45.279 6777-6786/com.example W/SQLiteConnectionPool﹕ A SQLiteConnection object for database '+data+data+com_example+databases+example_db' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed. 03-20 11:55:45.299 6777-6786/com.example W/CursorWrapperInner﹕ Cursor finalized without prior close()


How to close the cursor in getContentResolver (or) how to fix this error.


Aucun commentaire:

Enregistrer un commentaire