原因资产和原材料资源的Andr​​oid原材料、资产、原因、资源

2023-09-12 22:07:43 作者:我就是被你宠坏的

这是某种形式的哲学问题......。 我在我的研究,在Android世界的中期,我只是涵盖的资产和原始资源。

this is some sort of a philosophical question .. . I'm in the mid of my studies in the Android world and I just covered the Assets and Raw resources.

我想了解使用原始的资源与资产的原因。

I'm trying to understand the reason for using Raw resources vs. Assets.

他们都提供具有未资源的输入流。

They both provide with an uncompiled resource input stream.

看来,资产提供了更大的灵活性和功能性再生资源。

It seems that Assets provide much more flexibility and functionality then Raw resources.

一个。您可以根据资产创建文件夹结构,而不是生在

a. You can create folder structure under Assets and not under Raw

乙。你可以动态的资产文件夹,而不是列出原始文件夹中的所有资源。

b. you can list all resources dynamically in the assets folder and not in the Raw folder.

所以,我为什么要使用原始资源的Andr​​oid?

So why would i use Raw resources in Android ?

感谢。

推荐答案

文件夹和资产之间的主要区别文件夹。

由于原料是资源(RES)的子文件夹,Android将 自动生成一个 ID 对位于里面的任何文件。本 ID 然后存储在该研究班,将作为一个参考 一个文件,这意味着它可以从其他Android类很容易地访问 和方法,即使在机器人的X​​ML文件。使用自动 生成的ID是有机会获得在Android的一个文件的最快方式。

Since raw is a subfolder of Resources (res), Android will automatically generate an ID for any file located inside it. This ID is then stored an the R class that will act as a reference to a file, meaning it can be easily accessed from other Android classes and methods and even in Android XML files. Using the automatically generated ID is the fastest way to have access to a file in Android.

Assets文件夹是附件目录。在研究类完成 不生成的ID 作为摆在那里的文件,所以它的相容性较差 一些Android的类和方法。此外,这是要慢得多,以 访问里面的文件,,因为你将需要得到它的句柄 基于字符串。然而,一些操作被做得更容易 将这个文件夹中的文件,如复制数据库文件到 系统的内存。有没有(简单)的方法来创建一个Android XML 参考Assets文件夹中的文件。

The Assets folder is an "appendix" directory. The R class does not generate IDs for the files placed there, so its less compatible with some Android classes and methods. Also, it’s much slower to access a file inside it, since you will need to get a handle to it based on a String. However some operations are more easily done by placing files in this folder, like copying a database file to the system’s memory. There’s no (easy) way to create an Android XML reference to files inside the Assets folder.