06-09-2011 11:51 AM
I have a question regarding SQLite on BlackBerry OS 5.0 and up. Our application has two entry points, one background process that starts when the device boots and one GUI process that starts when the user clicks the application icon. Both of these processes require database access to the same database. For some reason, I can't seem to have two open connections to the database, I get a DatabaseIOException when I try to open the second connection (I also get a message that says "File System error 12"). Also, one of the SQLite statements hangs on the 'prepare' method, perhaps this is related to the two open connections, I don't know.
Can anyone help me with this?
06-09-2011 06:50 PM
Thanks for your reply! I guess I didn't exactly ask a direct question, but I posed a problem. But your post implies that it isn't possible to open two connections at all? So does that mean that it isn't possible to access the same database from two processes?
06-10-2011 01:18 PM
you should also be able to open read-only connections, what Im doing with a SQLite where another APP is storing GPS waypoints to as background APP. (ItÄs really another APP not only different access points because the GPS Tracker can run independently and can be 'used' from different other APPs. Using read-only connection I can display waypoints or routes in Map APP / Field.
If I want to insert / modify the GPS - Waypoints - SQLite DB from other APPs I'm using services provided by the GPS Tracker APP via remote (global) commands (OS 6).
also it can happen that there are some threads running from GPS Tracker APP (one tracking and storing waypoints, another one doing reverse geocoding and updating records) - in this case I'm using a synchronized object as mentioned in other replies.
06-13-2011 10:14 AM
Thanks for all of your replies! However, I haven't been able to fix it yet. i've tried putting the database helper in the runtime store and I've also tried read-only connections, but the system still seems to hang on the prepare method of one of the sqlitestatements. The debugger shows the following stack after a call to prepare():
It seems like there's deadlock or something, but I don't know what could be causing it. I'm sure that only one of the processes is accessing the database at the same time.
06-14-2011 04:37 AM - edited 06-15-2011 04:26 AM
04-06-2012 01:25 AM
You are opening your database again without closing it properly so that you are getting these type of problems. So you hae to do one database handling in the block and when you are try to using any database then after opening database in try block, make sure that you are closing database in the finally block.
If you are using threads and getting any runtime errors, then use synchronized block for each database handling code where you are opening and closing database. At the last of synchronized block, use notifyall() to run all blocks. This would very useful to you.
Press like button,. if you satisfied.