Thanks for the help (DDMS logcat, I didn't realize it tracked real
time activity).

It turns out it wasn't the sqlitedatabase query() method that was
causing the problem.

I had a line of code:
Random.nextInt(Cursor.getCount()) - 1
 to pick a random record from the returned cursor.
The problem is that the range is from -1 to Cursor.getCount() - 1 so
when nextInt(..) returned a -1, it was returning the Cursor BOF which
was throwing a CursorIndexOutOfBoundsException.

I just changed the line to:
Random.nextInt(Cursor.getCount() - 1)
 so that the range is from 0 to Cursor.getCount() - 1.

On Apr 15, 2:12 am, Raphael <[email protected]> wrote:
> Please look at the "adb logcat" error message (also Eclipse > DDMS
> perspective > logcat).
>
> R/
>
> On Tue, Apr 14, 2009 at 10:38 PM, iki <[email protected]> wrote:
>
> > The application has stopped unexpectedly.
> > Please try again.
>
> > One query always works.
> > Two consecutivequeriesworks about 75% of the time.
> > Three consecutivequeriesworks about a third.
> > Four consecutivequeriesworks about 10%
> > Five doesn't seem to work at all (it worked once out of many tries).
>
> > On Apr 13, 12:15 am, Ralf <[email protected]> wrote:
> >> What kind of "crash" do you get? Is this a force close or an exception?
> >> R/
>
> >> On Thu, Apr 9, 2009 at 9:26 PM, iki <[email protected]> wrote:
>
> >> > Has anyone other than me needed to make consecutivequeriesto a
> >> > sqlitedatabase?
> >> > My application works sometimes but other times (about 98% of the
> >> > time), the app will crash.
> >> > What I'm doing is using the sqlitedatabase.query(..) to return a
> >> > cursor which I parse,
> >> > I makemultiplesuccessivequeriesto the database and parse different
> >> > recordsets/cursors.
>
> >> > My question would be does a sqlitedatabase need to recover or clean up
> >> > after a .query is issued?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to