Cursor 是否具有独立数据,或者它只是指向数据的指针?
我收到 Gmail 客户端中存在的所有电子邮件:
final Cursor messages = getContentResolver().query(
Uri.parse("content://gmail-ls/conversations/" + mailAddress + "/"
+ String.valueOf(conversationId) + "/messages"), null, null, null,
null);
存在问题...有时,当 Gmail 客户端尝试查看是否有新电子邮件到达,而我同时阅读上述光标时,Gmail 崩溃并显示“IndexOutOfBoundException” 。这种情况发生过一百多次……大约是 1% 的次数。
第一个问题:我将尝试将消息 Cursor 复制到一个名为 copyCursur 的新 Cursor 中。
我不知道这个解决方案是否正确:例如,当我致电
messages.moveToLast();
A.它是否直接从“content://gmail-ls/conversations/”读取
B.或消息是“content://gmail-ls/conversations/”中包含的数据的副本?
因为如果是 A,也许我的解决方案可能会获胜。否则,如果是B,我的解决方案肯定是错误的。
第二个问题:如何复制Cursor? 如果我这样做是对的吗:
Cursor copyMessages = new Cursor();
copyMessages = messages;
或者以这种方式我只知道 copyMessages 是指向消息的“指针”?
非常感谢!
I get all the emails present in the Gmail client:
final Cursor messages = getContentResolver().query(
Uri.parse("content://gmail-ls/conversations/" + mailAddress + "/"
+ String.valueOf(conversationId) + "/messages"), null, null, null,
null);
There is an issue... Sometimes, when Gmail client try to see if a new email arrived, and I,m reading in the meanwhile the above cursor, Gmail crash with "IndexOutOfBoundException". This happens once over a hundred of times... in 1% of the times, moreabout.
First question: I will try to duplicate the messages Cursor into a new Cursor, called copyCursur.
I don't know if this solution is right: for example, when i call
messages.moveToLast();
A. does it read directly from "content://gmail-ls/conversations/"
B. or messages is a COPY itselt of the data conteined in "content://gmail-ls/conversations/"?
because if A, maybe my solution colud be winning. Otherwise, if B, my solution is surely wrong.
Second question: how to duplicate a Cursor?
Is it right, if I do:
Cursor copyMessages = new Cursor();
copyMessages = messages;
or in this way I've only that copyMessages is a "pointer" to messages?
Thanx very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个指针。
如果您想迭代缓存的数据,请使用 ContentQueryMap 类。
It's a pointer.
If you want to iterate over cached data, use ContentQueryMap class.