【发布时间】:2015-03-20 06:42:41
【问题描述】:
您好,在我的项目中,我正在使用 getContentResolver 方法在 for 循环中更新数据库。这是我用于更新数据库的编码
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()}
);
}
我收到错误
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()
如何在 getContentResolver 中关闭光标(或)如何修复此错误。
【问题讨论】:
-
你在哪里使用 ContentResolver.query() ?
-
阅读此SO post。可能你不止一次打开数据库
-
没有查询我只是使用更新方法更新
标签: android database sqlite cursor android-contentresolver