最好的办法在Android上一个单独的数据安装 [英] Best way to do a separate data install on Android

查看:129
本文介绍了最好的办法在Android上一个单独的数据安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要脱钩我的Andr​​oid应用程序从code的数据,我不知道要做到这一点的最好办法。

I want to decouple data from code on my Android application, and I am not sure of the best way to do that.

例如 - 与Linux麻将游戏,你可以通过删除一个特殊格式的文件到指定目录中添加新的瓷砖游戏。该麻将游戏会检查目录,当它启动。

For instance - with the Linux Mahjongg game you can add new tiles to the game by dropping a specially formatted file into a specific directory. The Mahjongg game checks that directory when it starts up.

我想要做同样的事情与我的Andr​​oid应用程序 - 我希望能够安装应用程序,然后对不同的数据文件单独安装。这是已经我挂了数据文件安装。我不希望有建立自己的服务器和写我自己的下载code。

I want to do the same thing with my Android app - I want to be able to install the app, and then have separate installs for different data files. It's the data file installs that have me hung up. I do not want to have to set up my own server and write my own download code.

推荐答案

您可以用安装程序附带的数据,然后使用输入/输出流,以将数据从资产或生迪尔斯复制。

You can ship the data with the installer app, then use Input/Output Streams to copy the data from the assets or raw dirs.

检查了这一点:

<一个href=\"http://stackoverflow.com/questions/513084/how-to-ship-an-android-application-with-a-database\">How与数据库出货的Andr​​oid应用程序?

答案已经在/ OutputStream中的实现。你并不需要使用数据库,只需将文件复制到存储分机

The answer has an implementation of in/outputstream. You don't need to use a db, just copy the file to ext storage.

一个重要的细节:如果你把文件中的资产,​​这将被运COM pressed,手机/标签将尝试uncom preSS在其内存全部文件。一(hocky)的方式,以避免对文件命名为.MP3。在mp3格式的资产不予COM pressed。 (喂!我说,这是hocky!)

One important detail: if you put the file in assets, it will be shipped compressed, and the phone/tab will try to uncompress the file in its entirety in memory. One (hocky) way to avoid that is to name the file .mp3. Assets in .mp3 format are not compressed. (Hey! I said it was hocky!)

安装程序的应用程序可以通过在意图使用ACTION_DELETE(见 HTTP自行卸载。 amberfog.com/?p=98 了解详细信息)或仅表现出味精,它可以安全地删除数据的应用程序给用户。

The installer app can either uninstall itself by using ACTION_DELETE in an intent (see http://android.amberfog.com/?p=98 for details) or just show a msg to the user that it's safe to delete the data app.

HTH,

llappall

这篇关于最好的办法在Android上一个单独的数据安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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