I forgot to mention that this exception happens (so far) from the service I have for updating database (is executed every 24 hours).
Cheersss, Armond > Hi Guys, > > I have different background threads in my application, one doing > periodical > database updates, another responsible for doing long searches and so. > Obviously some are just reading from database while others are writing as > well. > > Once in a while I get "database is locked" exception. I need to know the > safe way of reading/writing from/to database on different threads. > > As well I've found "isDbLockedByCurrentThread()" and > "isDbLockedByOtherThreads()" methods on SQLiteDatabase. Should I use them > every time I want to access the database? What if the database is locked? > Should I pause the current thread and retry a few milliseconds later? > > Best Regards, > Armond > > > 08-23 10:17:32.029 E/AndroidRuntime( 1331): Caused by: > android.database.sqlite.SQLiteException: error code 5: database is locked > > 08-23 10:17:32.029 E/AndroidRuntime( 1331): at > android.database.sqlite.SQLiteStatement.native_execute(Native Method) > > 08-23 10:17:32.029 E/AndroidRuntime( 1331): at > android.database.sqlite.SQLiteStatement.execute(SQLiteStatement.java:66) > > 08-23 10:17:32.029 E/AndroidRuntime( 1331): at > android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1534) > > 08-23 10:17:32.029 E/AndroidRuntime( 1331): at > com.test.db.TestDao.update (TestDao.java:327) > > 08-23 10:17:32.029 E/AndroidRuntime( 1331): at > com.test.UpdateService.onStart(UpdateService.java:35) > > 08-23 10:17:32.029 E/AndroidRuntime( 1331): at > android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2557) > > 08-23 10:17:32.029 E/AndroidRuntime( 1331): . 10 more > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---