2

I'm using Android 6.0 and SQLite 3.8.10.2 I have a problem with changing journal mode for my db connection.

Cursor cursor = null;
cursor = mDatabase.rawQuery("PRAGMA journal_mode", null);
Boolean d = cursor.moveToFirst();
String gg = cursor.getString(0);
cursor.close();

mDatabase.rawQuery("PRAGMA journal_mode=DELETE", null);

cursor = mDatabase.rawQuery("PRAGMA journal_mode", null);
Boolean dd = cursor.moveToFirst();
String xx = cursor.getString(0);
cursor.close();

First I check journal_mode and value is 'PERSIST' Then I set journal_mode=DELETE and check again, but value of xx variable is still PERSIST. I need to change journal_mode because I have to sync db between multiple devices.

Thanks

Bertram Gilfoyle
  • 9,899
  • 6
  • 42
  • 67
GigaKatowice
  • 551
  • 1
  • 6
  • 14

1 Answers1

0

It turns out that I have to write journal_mode=Delete instead of journal_mode=DELETE. Very strange, because documentation writes everything in capital letters.

GigaKatowice
  • 551
  • 1
  • 6
  • 14
  • Capitalization makes no difference whatsoever to SQLite. The [documentation](http://www.sqlite.org/pragma.html#pragma_journal_mode) says that "if the journal mode could not be changed, the original journal mode is returned". – CL. Jan 12 '18 at 19:52
  • 1
    @GigaKatowice did you try `execSQL`? When trying out VACUUMN, I think, I came across issues. Basically I use `rawQuery` for retrieving and `execSQL` for setting PRAGMA's. – MikeT Jan 12 '18 at 20:15
  • @MikeT Yes, I tried execSQL but it throws an exception. – GigaKatowice Jan 15 '18 at 07:32