简体   繁体   English

Android SQLite数据库导入记录

[英]Android SQLite database importing records

What is the best way to get aproxmatly 1900 records into a SQLite database when the app is first run? 首次运行应用程序时,将1900条记录发送到SQLite数据库的最佳方法是什么?

  1. Importing from text file 从文本文件导入
  2. Importing from code 从代码导入
  3. Downloading from the web 从网上下载
  4. Packaging the database with the app. 使用应用程序打包数据库。

Currently I important from a text file but this takes a couple of minutes to parse the xml first. 目前我对文本文件非常重要,但这需要花几分钟时间来解析xml。

Thanks. 谢谢。

I recommend to you to download from a webservice or Restful API. 我建议您从Web服务或Restful API下载。

Add the request into the onCreate() and onUpgrade() of your SQLiteOpenHelper to download it on every upgrade of the database if you are going to add/modify/delete any table of your DB. 如果要添加/修改/删除数据库的任何表,请将请求添加到SQLiteOpenHelper的onCreate()和onUpgrade()中,以便在每次升级数据库时下载它。

Regards 问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM