开发者

Does Cursor has standalone data or it is only a pointer to the data?

开发者 https://www.devze.com 2023-02-22 15:06 出处:网络
I get all the emails present in the Gmail client: final Cursor messages = getContentResolver().query( Uri.parse(\"content://gmail-ls/conversations/\" + mailAddress + \"/\"

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/conversat开发者_JAVA百科ions/"?

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!


It's a pointer. If you want to iterate over cached data, use ContentQueryMap class.

0

精彩评论

暂无评论...
验证码 换一张
取 消