安卓:如何存储可以在运行时更新的资源 [英] Android: how to store resources that may be updated at runtime
问题描述
什么是存储的声音文件(OGG)要分发与应用程序和更新在运行时的最佳方式?
What is the best way to store sound files (ogg) that are distributed with the app and updated at runtime?
我开发一个应用程序,包括声音的默认设置为资源(RES /生/ *。OGG)。这些做工精细的默认值,但我希望用户能够与录制的声音和下载互联网进行更新设定的声音。问题是,资源是只读的,并且我认为,资产也只读。我不知道如何在项目中包含的文件,使他们能够在运行时进行更新。
I am developing an app that includes a default set of sounds as resources (res/raw/*.ogg). These work fine for the defaults but I want the user to be able to update the set of sounds with recorded sounds and downloads from the Internet. The problem is that the resources are read-only and, I think, assets are also read-only. I don't know how to include files in the project so they can be updated at runtime.
我可以有默认值作为内部存储或SD卡运行时添加的资源和文件,但我会preFER有在一个地方的所有文件,以访问他们的一个接口。有没有一种方法,包括在该项目,以便它们将被写入内部存储或SD卡中的文件在安装应用程序时?或者,有没有更好的地方来存放这些文件?
I can have the defaults as resources and files added at runtime on internal storage or SD Card, but I would prefer to have all the files in one place with a single interface for accessing them. Is there a way to include files in the project so they are written to internal storage or SD Card when the app is installed? Or is there a better place to put the files?
推荐答案
包装.apk文件时,把你的文件 /资产
目录。在运行时复制这些文件在应用程序的内部存储 /数据/数据/< application_package_name> /文件
(如果文件不以多少大小,它有用的,当设备没有外部存储包括在内)。同时更新同一位置的文件。
Put your files in /asset
directory when packaging the .apk file. At runtime copy those files in application's internal storage /data/data/<application_package_name>/files
(If files are not to much sized, It useful when device has no external storage included). Also update the files in same location..
这篇关于安卓:如何存储可以在运行时更新的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!