12
我正在使用以下行循环Sqlite查询的行。有没有更快的方法来遍历Sqlite查询中的行?
this.open(); // opening db
Cursor cursor = db.rawQuery(strQuery, null);
cursor.moveToFirst();
do {
// do something
} while (cursor.moveToNext());
cursor.close();
当行数约为15000时,需要很长时间。 对于空while
块大约需要4秒,对于while
块需要大约6秒的代码块。它表明以这种方式在行上迭代是耗时的。
有没有更快的方式循环在android和Sqlite中的行?
感谢,
我不知道你的用例SQLite的,但是这可能是有用的:http://shopwith.it/2011/12/16/how-to-improve-android -app-performance-by-caching-data-in-sqlite-and-images-to-the-sd-card-android-developer-tips/ – Eric
如果你为它着想,你能解释为什么你需要检索这么多记录一次?你也不能在你的SELECT语句中折叠到更少? – 2012-09-02 09:12:54