Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 SQLite 表(超过 100000 行),我希望它的行流式传输。
我愿意:
Cursor cursor = db.rawQuery("SELECT _id FROM hugetable", new String[] {});
问题在于,仅将第一行设为:
cursor.moveToFirst()
似乎加载了整个表,速度很慢。
有没有办法在获取第一行时无需等待加载所有行就可以流式传输查询?
(就像我可以在 Android 之外使用普通的 C SQLite API 一样)
AndroidCursor旨在加载所有数据以进行缓存。
Cursor
要解决此问题,您必须按步骤手动查询数据:
SELECT _id FROM hugetable ORDER BY _id LIMIT 100; SELECT _id FROM hugetable WHERE _id > last_id_from_previous_query ORDER BY _id LIMIT 100;