Adding this line in my Android code forced the commit from the wal
file into the main database:
db.rawQuery("PRAGMA wal_autocheckpoint = 1", null);
// db is an instance of SQLiteDatabase, i.e.
// SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(/sdcard/
mydb.db, null);
I use autocheckpoint value of 1, which is the page size that will
trigger the checkpoint. The default is 1000.
I noticed the same behavior when the onUpgrade() method would add new
tables to the main database, but I didn't see them when querying
the .db file. If I tried to re-add the tables through code, I would
get SQL Exceptions that the tables already existed (in the wal file).
The application I am working on was written on an Android 1.6 platform
(prior to sqlite 3.7 and before WAL was added to sqlite). I just
noticed the onUpgrade() issue running the application on an Android
2.3.4 device which has sqlite 3.7.
Hope that helps
On Jan 13, 1:35 am, Susan <[email protected]> wrote:
> I want to copy database file to SD card. But Write-Ahead Log (wal
> file) has not writen to db file. It will write to db file when
> checkpoint occurs as the SQLite offical document said
> :http://www.sqlite.org/wal.html#ckpt.
> So is there an API I can trigger a checkpoint of database, so after
> that I can copy the db file to SD card?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en