What's the easiest way to populate a SQLLite table with data off a URL?
I'm writing a Delphi web app that will generate a file on a server for my Android app to download.
In Delphi, I'll probably save it as a开发者_如何学Python .csv file and use bulk import to import into MS SQL Server.
What's the easiest / best practice way to do this in Android? How would I download the file from the URL and then load it into SQLLite?
Many thanks for any pointers.
How would I download the file from the URL
Use HttpClient, as Frayser indicates.
and then load it into SQLLite?
You neglected to tell us what format you will use for the download.
If the format is the CSV you mentioned for other uses, parse it and use SQL INSERT
statements (execSQL()
or insert()
with your SQLiteDatabase
object). Wrap the INSERT
statements in a transaction to improve performance, since each transaction requires a flash write, and flash writes are slow.
If you are downloading a complete SQLite database, just put it in getDatabasePath()
, and open it when needed.
精彩评论