2

I'm currently developing an Android app with ORMLite.

My problem is that i have to do big database transaction in the background while the user wants to read some data from the database. The unacceptable result is that the app does not respond until the transaction is finished.

I have read many about transactions and ORMLite now but I am still not sure how to solve the problem. I think that i want do a "non-exclusive" transaction (or also called "immediate mode").

If this is right, how can i do such an transaction with ORMLite?

Benny
  • 133
  • 8
  • What is your background task ? Maybe it can be optimize to be faster. :) – Eliott Roynette Sep 04 '14 at 09:43
  • The background task is optimized as much as possible. But even if not this can not be the solution. The transaction in the background should never influence the response time of the UI. – Benny Sep 04 '14 at 12:00
  • Fair enough, I don't know how you can manage that without manage your background task (like stop it and restart). I +1 your question and wait for an answer from someone better than me :P – Eliott Roynette Sep 04 '14 at 12:04

1 Answers1

1

After spending 2 days reading documentations and blogs I found the answer!

It just one method call on the SQLiteDatabase which does the job:

enableWriteAheadLogging()

That's it. Now I can read and write simultaneously.

For more information have a look at SQLite simultaneous reading and writing

Community
  • 1
  • 1
Benny
  • 133
  • 8