Android-预先填充的数据库,要插入还是预先加载? [英] Android - Pre-populated Database, insert or pre-loaded?

查看:55
本文介绍了Android-预先填充的数据库,要插入还是预先加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个应用程序,该应用程序目前在其少数几个表之一中具有11列和120〜行的文本数据.它可能是为用户预先填充的唯一表,但是,我试图弄清楚填充数据的最佳方法是什么.我看到了几种不同的选择.

I am building an application which currently has 11 columns and 120~ rows of text data in one of its few tables. It will likely be the only table which is pre-populated for the user, however, I am trying to figure out what the best method is for populating the data. I see a few different options.

  1. 在数据库创建期间运行插入语句
  2. 在资产文件夹中创建一个已经有数据的表并将其复制创建应用程序时.

这种事情的最佳实践是什么?随着时间的流逝,数据库将更新多行.我每月可能要看几行,没有什么太大的.

What is the best practice for something like this? Over time, the database will be updated with a few more rows. I am looking at maybe a few rows a month, nothing too big.

任何帮助将不胜感激.

推荐答案

这种事情的最佳实践是什么?

What is the best practice for something like this?

选项2,特别是使用 SQLiteAssetHelper .它比执行SQL事务更快,并且随着您预加载的内容变得更加复杂而变得更加容易.

Option #2, specifically using SQLiteAssetHelper. It will be faster than executing SQL transactions and is easier as your pre-loaded contents get more complicated.

随着时间的流逝,数据库将更新多行.我每月可能要看几行,没有什么太大的.

Over time, the database will be updated with a few more rows. I am looking at maybe a few rows a month, nothing too big.

如果数据库是纯只读的(即在运行时基于用户输入的应用程序不会对其进行修改),则可以选择通过对应用程序本身的更新来分发更新.否则,您可能需要下载有关这些更改的信息并应用它们,这可能是为了响应GCM消息或偶尔进行的轮询检查.

If the database is purely read-only (i.e., will not be modified by your app at runtime based on user input), you have the option of distributing your updates via updates to the app itself. Otherwise, you will need to download the information for those changes and apply them, perhaps in response to a GCM message or a very occasional polling check.

这篇关于Android-预先填充的数据库,要插入还是预先加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆