Hello everyone,
I'm working on a Phonegap project(android) where I need to use SQLite WAL mode so that there will be no concurrent Write operations as I'm facing SQLite Locked Exception(Database is locked).
I have executed following query in my Database Adapter :
db.execSQL("PRAGMA journal_mode=WAL");
as I have studied from http://ift.tt/1j4yrew that the PRAGMA statement is issued using the same interface as other SQLite commands (e.g. SELECT, INSERT).
I'm also enabled & disabled WAL mode in Database Adapter open & close functions.
/* Function to open Database */
public DatabaseAdapter open() throws SQLException {
db = dbh.getWritableDatabase();
try{
db.enableWriteAheadLogging();
Log.d(TAG, "Database Write Ahead Logging ENABLED");
// .... a transaction, in a separate thread, happen here and I wait the other thread to close the transaction before proceeding into the finally ...
} finally {
}
return this;
}
/* Function to close Database */
public void close() {
try {
Log.d(TAG, "Trying to disable Database Write Ahead Logging");
db.disableWriteAheadLogging();
Log.d(TAG, String.format("Database Write Ahead Logging is %s", db.isWriteAheadLoggingEnabled() ? "STILL ENABLED" : "DISABLED"));
} catch (IllegalStateException e) {
Log.w(TAG, "Couldn't disable Database Write Ahead Logging, a transaction is probably still open", e);
}
dbh.close();
}
But WAl mode not getting set using this. I have read a post (Storage of SQLite database using Android and Phonegap ) which says 0000000000000001.db-wal is created after enabling WAL mode.
Please let me know if I'm missing something.
I have few questions :
- Is there anything that I need to set in javascript part also?
- Is there any changes which are required in SQLite Plugin?
- How to use WAl mode Checkpoints?
Aucun commentaire:
Enregistrer un commentaire