1

Currently having an issue in a XF app where my SQLite db3 file is always showing empty (when I copy it off the device/etc). When I go into ADB Shell and look at the directory listing, I see it and the shared memory files db3-shm/db3-wal. These files are much larger like they are the actual ones containing the data. Any ideas?

Using the sqlite-net-pcl package and running on Android 8.1.0

File Listing

Contissi
  • 41
  • 1
  • 8
  • Possible duplicate of [-shm and -wal files in SQLite DB](https://stackoverflow.com/questions/12928294/shm-and-wal-files-in-sqlite-db) – Alex P. Oct 02 '18 at 19:56

2 Answers2

0

You can restart/truncate the write-ahead log using the SQLite PRAGMA SQL statement via ExecuteScalarAsync.

var result = await conn.ExecuteScalarAsync<int>("PRAGMA wal_checkpoint(TRUNCATE);", new string[] { });

re: https://sqlite.org/pragma.html#pragma_wal_checkpoint

Examples:

PRAGMA schema.wal_checkpoint;
PRAGMA schema.wal_checkpoint(PASSIVE);
PRAGMA schema.wal_checkpoint(FULL);
PRAGMA schema.wal_checkpoint(RESTART);
PRAGMA schema.wal_checkpoint(TRUNCATE);
SushiHangover
  • 73,120
  • 10
  • 106
  • 165
  • I ended up rolling back to a previous SQLite nuget package (before WAL support) until I can research further. I will be sure to check out your links and attempt to understand it better. Appreciate the response!! – Contissi Oct 03 '18 at 18:50
0

I also faced this issue.. I had copied .db3-shm and .db3-wal files alongside .db3 file to see data in DB browser for sqlite .. I presume data is stored in these files .. You can read about them here.. https://www.sqlite.org/fileformat2.html#walindexformat

niketan
  • 812
  • 11
  • 13