Backup Room database

后端 未结 7 820
夕颜
夕颜 2020-12-08 01:41

I\'m trying to backup a room database programmatically.

For that, I\'m simply copying the .sqlite file that contains the whole database

But, bef

7条回答
  •  悲哀的现实
    2020-12-08 02:00

    First, the database must be closed to apply changes from the "dbName.db-wal" file.

    Then you can copy the database with all tables and last data changes

     AppDatabase appDatabase = AppDatabase.getAppDatabase(getApplicationContext());
     appDatabase.close();
    

提交回复
热议问题