如何运输Android应用程序与数据库? [英] How to ship an Android application with a database?

查看:238
本文介绍了如何运输Android应用程序与数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果你的应用需要一个数据库,并配有内置的数据,究竟是把该应用程序的最佳方法是什么?

If your application requires a database, and comes with built in data, what is the best way to ship that application?

1)precreate SQLite数据库,其中包括它在APK?

1) Precreate the sqlite database and include it in the apk?

2)包括与该应用程序的SQL命令,并让它创建数据库和插入数据在第一次使用?

2) Include the SQL commands with the application and have it create the database and insert the data on first use?

缺点我看

1)可能的sqlite的版本不匹配可能导致问题,我目前不知道是哪里的数据库应该去以及如何访问它。

1) Possible sqlite version mismatches might cause problems, and I currently don't know where the database should go and how to access it.

2)可能需要很长的时间,在设备上创建和填充数据库。

2) It may take a really long time to create and populate the database on the device.

您的想法?有关的任何问题指向的文件将是巨大的。

Your thoughts? Pointers to documentation regarding any issues would be great.

推荐答案

我刚刚找到一个办法做到这一点的ReignDesign博客在一篇题为的使用您自己的SQLite数据库在Android应用程序的。基本上你precreate数据库,把它放在你的资产目录中的APK,并在第一次使用拷贝到/数据/数据​​/ YOUR_PACKAGE /数据库/目录下。

I just found a way to do this in ReignDesign blog in an article titled Using your own SQLite database in Android applications. Basically you precreate your database, put it in your assets directory in your apk, and on first use copy to "/data/data/YOUR_PACKAGE/databases/" directory.

这篇关于如何运输Android应用程序与数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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