Open deshario opened 5 years ago
Even your export code above does not work reliably, because databases consist of more than one file (at least from Android Pie onwards, which enabled write-ahead logging by default). You'll have to use sqlite commands to make sure your export is aware of latest sqlite features (such as write-ahead logging). One way to safely export a database is to run sqlite3's own .dump command (i.e. run /system/bin/sqlite3 /path/to/database .dump
). That command's output is SQL that will recreate the database.
Obviously, you will also need to make sure that no concurrent access on the database is happening. It's best to close the database before dumping it, and make sure the database doesn't exist before restoring it.
How to import and export "dbname.db" ?