Try having both components are using the same SQLiteDatabase object (e.g., via a singleton). SQLiteDatabase has its own thread-safety logic, but that only works with one instance, not across multiple instances.
On Mon, Oct 10, 2011 at 9:53 PM, Zsolt Vasvari <[email protected]> wrote: > Hello, I have my app with its UI and a periodic Service both accessing > the same SQLite database. > > It appears when the Service is trying to hit the database and the UI > has it open, I am getting a SQLiteException: > > android.database.sqlite.SQLiteDiskIOException: disk I/O error > at android.database.sqlite.SQLiteDatabase.native_setLocale(Native > Method) > at > android.database.sqlite.SQLiteDatabase.setLocale(SQLiteDatabase.java: > 2101) > at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java: > 1969) > at > android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java: > 902 > > > I am opening the database see that I can call > isDbLockedByCurrentThread() on it, but it's not even getting that > far. It's kind of like a chicken/egg situation as I cannot open the > database to see it's locked, because it's crashing first. > > I am using SQLiteDatabase.openDatabase(this.file, null, > SQLiteDatabase.OPEN_READWRITE) to open the database. > > Anybody has a clue how to get around this? > > -- > 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 > -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 2.0 Available! -- 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

