【发布时间】:2012-08-24 17:33:34
【问题描述】:
我的代码有一些 sqlite 运算符。我执行一个 sql,它有 500 行。执行和获取行需要很短的时间,但是当我调用 cursor.close() 函数时,需要 10 秒。
我怎样才能减少这个时间消耗?
Cursor cursor = database.rawQuery(sql, null);
while(cursor.moveToNext()){
String str1 = cursor.getString(0);
String str2 = cursor.getString(1);
System.out.println(str1+" and "+str2);
}
cursor.close(); // this line takes 13 seconds. but above code takes only 200 ms
代码是这样的
【问题讨论】:
-
你试过关闭数据库对象而不是关闭游标吗??
-
不,我不尝试。但是,我需要数据库对象来进行下一个查询。