当前位置: 动力学知识库 > 问答 > 编程问答 >

android - 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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: