开发者

Where to put custom data

In a typical Android project you have the res/drawable directories where you can put images but I have some special custom binary files.

Where do I 开发者_运维技巧usually put them and can I access them via the R-class then?


Either in res/raw or res/assets. Read more in the Android docs.

About files in res/raw:

Arbitrary files to save in their raw form. Files in here are not compressed by the system. To open these resources with a raw InputStream, call Resources.openRawResource() with the resource ID, which is R.raw.filename.

However, if you need access to original file names and file hierarchy, you might consider saving some resources in the assets/ directory (instead of res/raw/). Files in assets/ are not given a resource ID, so you can read them only using AssetManager.AssetManager.


For such type of resources use res/raw directory.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜