Backup SQLite using Java

谁都会走 提交于 2019-12-13 00:41:49

问题


I need to create a Java class that creates a backup of my database. My problem is, I don't know how to do this using a SQLite database. Can anyone show me how?


回答1:


If the database is reasonably small, you can just call BEGIN EXCLUSIVE TRANSACTION to prevent other processes from modifying the database, then copy the database file, then ROLLBACK TRANSACTION. If the file is huge, you'll have to use the online backup interface (if your Java bindings don't support it, use JNI).

Of course, if there's just your app using this database and you can be sure that nobody's going to modify the file while you're copying it, just go for it and copy.




回答2:


The easiest thing is to create a copy of the database file- assuming it is a disk-based DB.



来源:https://stackoverflow.com/questions/11245244/backup-sqlite-using-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!