How to import pre-made db to sqlite managed by ormlite

前端 未结 2 931
死守一世寂寞
死守一世寂寞 2021-02-04 17:46

I have a .db file and I want to setup it at first run of my android application. I use OrmLite to manage my database.

In that .db file a have about 7000 records and when

2条回答
  •  不要未来只要你来
    2021-02-04 18:30

    If you want to provide the data as an external db, you can dump on or more tables (definition and data) using

    sqlite3 prepared.db ".dump mytable" > dump.sql
    

    and import them using

    sqlite3 main.db < dump.sql
    

    If you want to setup things programmatically in Java, make sure that you do everything in one single transaction using TransactionManager.callInTransaction, since multiple commits (autocommits) are quite expensive in SQLite.

提交回复
热议问题