将光标传递给服务
我有一个可能很大的列表视图(10k+ 项)。当用户单击列表中的某个项目时,我在需要光标才能访问整个列表的服务中执行操作。由于我无法通过活动中的 Intent 传递光标,因此我只需将所选项目的 id 发送到服务,然后根据此 id 重新查询数据库。但是,由于这是一个包含大量数据的复杂查询,因此可能需要一段时间。将此游标放在可解析类中而不是重新查询数据库会更快吗?然后我可以将 Intent 中的可解析类传递给 Activity。
谢谢
I have a list view that could be potentially large (10k+ items). When the user clicks on an item in the list, I take an action in a Service which needs the cursor for access to the entire list. Since I cant pass the cursor through an Intent from the activity I just send the id of the selected item to the Service then requery the database based off of this id. However, since this is a complex query with a lot of data, it can potentially take a while. Would it be faster to have this cursor in a Parseable class instead of requerying the database? I can then pass the parseable class in an Intent to the Activity.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用游标窗口来打包来自游标的数据。如果您没有执行任何写入操作:
如果您想要执行写入操作,那么您需要查询并获取游标,因为游标窗口缓存了数据而没有其他任何内容。
http://developer.android.com/reference/android/database/CursorWindow.html干杯
。
You can use a cursor window to parcel data from a cursor.If you are not doing any write operations:
In case you want to do write operation then you need to query and get a cursor,since cursorwindow caches the data and nothing else much.
http://developer.android.com/reference/android/database/CursorWindow.html
Cheers.