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. Media Player restarts during call

If the media player is streaming and audio file when you get a phone
call, the audio either stops or restarts after the phone call. how do
I fix this?

-- 

2. Help with user notification/dialog

I'm trying to replicate some functionality that I've seen, but can't
seem to figure it out.
Specifically, the Timer application included in HTC Sense generates a
dialog message with a "Dismiss" button.
This dialog appears regardless of what Activity is running and can
also appear when on the home screen.
The dialog does not bring the Timer application back to the
foreground.
The dialog can be dismissed by clicking the dismiss button.

I know that the NotificationManager is the preferred method to notify
a user of an event.  However, I would still like to be able to
replicate the functionality that is included in HTC's Timer app.

-- 

3. ACTION_HEADSET_PLUG without everlasting service possible?

4. sd card autorun on 2.2

5. How to check the which application is calling from framework

6. disable double touch keyboard

7. PopupWindow and scrolling