Some good background reading https://sqlite.org/wal.html
Answer to 3.
Use https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase#disableWriteAheadLogging() in the onConfigure
of SQLiteOpenHelper (or in your case you probably have to extend and override the SugarDb class to do that.
You will probably have to extend getInstance
as well to return your an instance of your own class (and not call super I think in that override), then where you call SugarDb.getInstance()
you call getInstance
on your extended class.
Answer to 2. As @CommonsWare says if your DB is closed correctly then all data is commited to the DB file from the Wal file on close.
Update:
Looking at https://github.com/chennaione/sugar/blob/master/library/src/main/java/com/orm/SugarDb.java
For every time you have called SugarDb.getReadableDatabase()
or SugarDb.getWritableDatabase()
you should call SugarDb.close()
The easiest way to do that is as soon as you have finished the current database operations as you cannot query it's connection count, or you could maintain your own count and close at various times in the apps lifecycle like onPause
or onDestroy
or before your try to backup
Answer to 1. https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase#isWriteAheadLoggingEnabled()