0

I want to implement WAL in Android, but there is not much documentation about this. I read the WAL documentation on SQLite Here but its not clear enough on how to port it to Android.

This question also sheds some light but I am not sure if executing only one statement will do.

Background of the problem

Any help would be highly appreciated

Community
  • 1
  • 1
User3
  • 2,465
  • 8
  • 41
  • 84
  • I added the [`database.enableWriteAheadLogging();`](http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#enableWriteAheadLogging%28%29) in my open() method in a class that I open/close the DB. I think it bugged it since I couldn't see anything in the SQLite Database Browser, but data was available to the app. Maybe I am using it incorrectly, but I hope this is a start. – Yordan Lyubenov Jan 23 '14 at 14:11
  • @YordanLyubenov The enableWriteAheadLogging function needs to be called only once, after the DB has been created. – CL. Jan 23 '14 at 14:13
  • Its exactly teh same for me, there is some bug too also it works only for certain versions of SQlite. have to take all this into consideration. – User3 Jan 23 '14 at 14:13
  • It would be great if you provide me with an example or an algo. – User3 Jan 23 '14 at 14:18
  • @CL I used one of the PRAGMA functions to do it once in onCreate in my own implementation in the SQLiteOpenHelper class, but it didn't work there. You suggest this is used in there? And, more importantly, used there in onCreate? – Yordan Lyubenov Jan 23 '14 at 14:21
  • Oops, WAL is persistent but your problem should not be that WAL is not working. It is more likely that your lock is causing trouble since not even WAL allows 2 threads to have write access at the same time. Look at transactions in Immediate mode, that might be something that could help. – zapl Jan 23 '14 at 14:28
  • I have only two threads, I got rid of the lock one of the thread will read and one will write. I am researching about it more and will update with details here. – User3 Jan 23 '14 at 14:48
  • can't you just call `enableWriteAheadLogging` on your DB? https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#enableWriteAheadLogging() – Budius Jan 23 '14 at 15:28
  • I am trying something like that only but I am not sure where and how to use these methods, I found something here https://android.googlesource.com/platform/frameworks/base/+/9a7debe5857ffc7c71cfc4082b1b6d72a5cf81cd/core/java/android/database/sqlite/SQLiteDatabase.java still trying to grasp it. – User3 Jan 23 '14 at 15:30

0 Answers0