I am trying to alter the journal_mode for my database, through code. I tried SQLiteDatabase.execSQL("PRAGMA journal_mode=OFF") but it fails because, the expression "PRAGMA journal_mode=OFF" returns a result (I verified this from the terminal), and so Android thinks this is a query and complains that I should be using execQuery instead. But what I am trying to execute isn't a query.
I also tried compiling the pragma expression to a SQLiteStatement and invoked the execute method, but same result.
Can someone suggest any alternatives to make this work through code?
Thanks, Ranjit
Perhaps you are suffering from this problem that the execSQL docs talk about:
Check that you are not using write ahead logging and then it might work.
It can be done with the next command:
(No need to create a
Cursor
as it is suggested in one of the comments to Robert's answer)