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. BOOT_COMPLETED broadcast sent much later on some devices than others



Which devices?

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 3.0
Available!

-- 

2. Receive Binary SMS on a specific port?

hey there,

is it possible to receive a binary SMS on a specific port?

i am currently receiving SMS via Action: "android.provider.Telephony.SMS_RECEIVED" from a BroadcastReceiver. But i have no luck with binary SMS. I only get notified for text messages. any suggestions? cheers timo --

3. Time for my n1 to sleep

4. How to Create a List with Overlapping Items

5. BOOT_COMPLETED broadcast sent much later on some devices than others

6. need suggestion on how to create views at run time and efficiently

7. ADEProxy.exe and adb server out of date?