Hard to describe ... How to quickly scan through all rows?! How to pass a cursor between two activities?!

by Mariano Kamp » Sat, 10 Apr 2010 01:51:28 GMT


Sponsored Links
 Hi,

  I have an app that has a list view of messages and a detail view. If you
click on a message in the list view the detail view is opened for the
message in the row you clicked on.
In the detail view you also can go back and forth to other messages. So I
pass in the position of the row the user clicked on and the criteria I need
to rebuild the cursor like I did for the list. Then I use
Cursor.moveToPosition() to get to the selected row.

  So far so good. There is only one issue, when an import is running in the
background that inserts new (or deletes aged) messages then between the time
of the click and the time the detail view queries the database again it
maybe that the position is not valid anymore.

  Any idea how to deal with that?

  I tried to pass in a key instead and then go through all rows until I find
the one that has the same key, but this takes a real long time and doesn't
seem feasable at all. But maybe I am doing it wrong. It looks something like
this:

while (contentCursor.moveToNext()) {
   if (42 == contentCursor.getLong(0))
      break;
}

  Any better way to do that in general?

  I could try what happens when I pass in the position also and start from
there. Usually that should work and when it doesn't then I could scan all
messages?! The problem is, scanning all say 1,000 articles may take more
than 5 seconds on a G1.

Cheers,
Mariano

--



Other Threads

1. how to overlay an image over the camera preview?

There is an Api Demo showing how to generally do this with a surface view.
It's very easy, since SurfaceView essentially operates like any other view
in terms of compositing.






-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~---------~--~----~------------~-------~--~----~

2. When does my thread die?

Hello,

I've created an app that functions as a countdown timer via a thread,
a wakelock, and a handler back to my activity. My question is, what
will cause my thread to die, or app to not be running in memory
anymore? I've had this happen once, and can't seem to recreate it
again.

Thanks in advance!
--~--~---------~--~----~------------~-------~--~----~

3. Swapping in and out ViewGroups (Layout) within a container ViewGroup.

4. Swivel-Chair Potatoes

5. Need help in running the android junit test case for andriod APIDemo in eclipse

6. ADP1 not showing in ddms

7. Swapping in and out ViewGroups (Layout) within a container ViewGroup.