1

On various occasions I receive log errors like this

my.app:sync E/SQLiteLog: (5) statement aborts at 1: [PRAGMA journal_mode=TRUNCATE] database is locked

While investigating into this issue I realized that my application (App.java) is sometimes initialized multiple times. My application needs to perform background operations on the database, for this purpose the AndroidManifest.xml spawns a service, which is set to android:process=":sync".

If a service is destined to run in a separate process, it will receive its own App instance (see https://stackoverflow.com/a/28498115/2416394) Now sometimes the application was spawned from the main thread and sometimes additionally from the sync process accessing the same file leading to the lock issue above.

Does somebody have an idea on how to actually access GreenDao in such a scenario? Other people have issues with that as well, but everything I found so far is very old and the only possible thing seems a "ContentProvider" but there is no documentation on how to actually use GreenDao 3 with a content provider.

Samuel
  • 6,126
  • 35
  • 70

0 Answers0