在我的应用程序中,我必须在SQLite数据库android中插入或更新Bulk of record, 记录大小可能达到3000或更大,
String query="SELECT * FROM tableName where "+id+" = "+bean.id()+" and "+other_id+" = "+bean.otherID();
Cursor mCount= db.rawQuery(query , null);
mCount.moveToFirst();
row=mCount.getCount();
mCount.close();
/**
* Insert here
*/
if(row==0){
ContentValues values = new ContentValues();
values.put(key, "value");
values.put(key, "value");
db.insert("tableName", null, values);
}
/**
* Updated here
*/
else{
ContentValues values = new ContentValues();
values.put(key, "value");
values.put(key, "value");
db.update("tableName", values, "id"+" = ? and "+"other_id"+" = ? ", new String[] {bena.id(),bean.otherid});
}
此代码工作正常,但需要花费很多时间,如何减少这段时间,或批量插入或更新记录。