Android中Raw和Asset的区别

时间:2016年3月18日13:35:54

相同点:
    两个文件夹下的文件都不会被编译成二进制文件,都会被原封不动的放到apk中。

不同点:
  1.     asset下的文件不会被映射到R文件中,raw下的文件会被映射到R文件中。
  2.     因为raw文件可以映射到R文件中,所以可以使用R.raw.xxx的方法去引用资源。
  3.     asset下可以有目录结构,raw下不能有目录结构。


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

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






转载于:https://www.cnblogs.com/yuzhongzheng/p/5412576.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值