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
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

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?


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. == Type ahead search timer ==

I am implementing a type ahead search so that results are returned as
the user is typing.  I want to have a timer so that the search is not
sent to the server until the user stops typing.  "Stops typing" is
defined by a number of milliseconds.  I figure that I can use a Timer
to start the search in another thread.  If another type ahead
character is received then I can restart the timer.  Is this a
reasonable approach or is there a simpler way?



2. Audio corruption during screen is off


Sometimes I am getting corrupted audio with Audiorecord class while
screen is off (When the proximity sensor used, or after idle screen

Help me to solve this issue if anyone is aware this issue.



3. start Activity in reciver class

4. Android Low Memory Killer + kswapd

5. Android, WinPho7, iPhone4... What Grills Faster?

6. How to Access JPEG hardware decoder

7. helppp maps google di nexus one kok tidak akurat