Android: SQLite database created with room shows no tables when opening with sqlte-browser

前端 未结 4 1174
别那么骄傲
别那么骄傲 2021-02-05 08:24

I am using Room Persistence Library 1.1.0. I could find the database file at /data/data//databases/ using Android Studio\'s De

4条回答
  •  自闭症患者
    2021-02-05 09:19

    You can use the wal_checkpoint pragma to trigger a checkpoint which will move the WAL file transactions back into the database.

            theRoomDb.query("pragma wal_checkpoint(full)", null)
    

    or

            // the result
            // contains 1 row with 3 columns
            // busy, log, checkpointed
            Cursor cursor = theRoomDb.query("pragma wal_checkpoint(full)", null)
    

    See PRAGMA Statements for more details about the pragma parameter values and results.

    If the WAL is not enabled the pragma does nothing. By the way, I tested with Room 1.1.1, and the WAL mode was not used by default, I had to enable it.

提交回复
热议问题