Download SQLite database from Internet and load into Android application
android, download, sqlite
Solution
One solution would be to include the (splitted) database in the assets folder and copy it to the database directory on the first startup.
It would not have to be split, just ZIPped. See `SQLiteAssetHelper` for an example.
How could I do this?
Use `HttpUrlConnection`. Or, use `HttpClient`.
Can I download a complete SQLite file and save it to the database directory?
Yes. Use `getDatabasePath()` to get the correct local path to use.
Or should I rather go with JSON data files that are used to populate the database?
You could, but for 45MB, that would be ghastly slow.
Problem
For my android application, I would like to use a large database (about 45 MB). One solution would be to include the (splitted) database in the assets folder and copy it to the database directory on the first startup. But this would consume disk space twice - one time in the assets folder where the file can't be deleted and one time in the database directory where it has been copied to. So I would rather like to download the database from the Internet (webserver) on the first startup. How could I do this? Can I download a complete SQLite file and save it to the database directory? Or should I rather go with JSON data files that are used to populate the database?