multiple successive queries to a database

by iki » Mon, 13 Apr 2009 12:04:08 GMT


Sponsored Links
 Has anyone other than me needed to make consecutive queries to 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 make multiple successive queries to 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?

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



multiple successive queries to a database

by Ralf » Mon, 13 Apr 2009 12:15:36 GMT


 What kind of "crash" do you get? Is this a force close or an exception?
R/




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


Sponsored Links


multiple successive queries to a database

by iki » Wed, 15 Apr 2009 13:39:04 GMT


 The application has stopped unexpectedly.
Please try again.

One query always works.
Two consecutive queries works about 75% of the time.
Three consecutive queries works about a third.
Four consecutive queries works about 10%
Five doesn't seem to work at all (it worked once out of many tries).




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



multiple successive queries to a database

by iki » Thu, 16 Apr 2009 07:58:28 GMT


 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.






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



Other Threads

1. Honeycomb + landscape + Mac = will not stay in landscape

Hey all,

I've seen the workaround posted to get landscape mode ..and it works ...but
only for a split second. Then the screen reverts back to portrait mode
displaying sideways. Driving me nuts! Anyone else seen this on OS X?

Cheers,
Stace

-- 

2. phone keypad intent?

In a fashion similar to IMAGE_CAPTURE returning an image from the
camera, I would like to discover an intent to utilize the phone
application's pleasant keypad and *return* the number entered (without
dialing). I haven't found such an intent yet... It seems that this
would be a  natural fit for the factory phone app.

I am already utilizing the ACTION_PICK from the contacts list; the
desire for keypad entry is for numbers that are not in the contact
list.

Thanks for your recommendations.

-Kirk

-- 

3. Activity without UI

4. Touch Screen Scrolling is not working on android-2.3

5. "Send via..."-integration?

6. GOT IT! (was -- WTB: Droid 2 Global)

7. how to manually update nesus s to android 2.3.3