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 I want to import it by common methods (use foreach - create command ) it takes many time (about 2-3 mins) to import.
How can i solve this problem?
thanks
Let say you have database named "
prepared.db
" and your package name is "com.example.android
". This is what I do.(Both Step 2 and 3 happen inside constructor)
This is code sample and It work for me.
P.S : If the database file size is more than 1mb, error will occur. You can split database to solve such issue.
If you want to provide the data as an external db, you can dump on or more tables (definition and data) using
and import them using
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.