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?
It would not have to be split, just ZIPped. See
SQLiteAssetHelperfor an example.Use
HttpUrlConnection. Or, useHttpClient.Yes. Use
getDatabasePath()to get the correct local path to use.You could, but for 45MB, that would be ghastly slow.