问题
What is the best way to store sound files (ogg) that are distributed with the app and updated at runtime?
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.
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?
回答1:
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..
来源:https://stackoverflow.com/questions/11151764/android-how-to-store-resources-that-may-be-updated-at-runtime