android工程中assets文件夹是干什么用的!

csf 2011-08-14 10:25:09
android工程中assets文件夹是干什么用的!为什么总是空的?能不能删了?
...全文
11346 29 打赏 收藏 转发到动态 举报
写回复
用AI写文章
29 条回复
切换为时间正序
请发表友善的回复…
发表回复
三个达不丢 2012-03-30
  • 打赏
  • 举报
回复
难以理解啊!
-droidcoffee- 2011-08-18
  • 打赏
  • 举报
回复
[Quote=引用 24 楼 tmxkdldw 的回复:]

fontlose 说得最好了。。
什么web html ..胡说八道。。。
[/Quote]
别告诉我你写web的时候不用assets
-droidcoffee- 2011-08-18
  • 打赏
  • 举报
回复
[Quote=引用 24 楼 tmxkdldw 的回复:]

fontlose 说得最好了。。
什么web html ..胡说八道。。。
[/Quote]

别告诉我你写web的时候不用assets
-droidcoffee- 2011-08-18
  • 打赏
  • 举报
回复
[Quote=引用 24 楼 tmxkdldw 的回复:]

fontlose 说得最好了。。
什么web html ..胡说八道。。。
[/Quote]
我擦 装什么装 恶心
domonate 2011-08-18
  • 打赏
  • 举报
回复
学习,mark!
tmxkdldw 2011-08-18
  • 打赏
  • 举报
回复
fontlose 说得最好了。。
什么web html ..胡说八道。。。
csf 2011-08-17
  • 打赏
  • 举报
回复
这分太少,没法给呀!给谁呢!呵呵!要么平分吧!哈哈哈……
csf 2011-08-17
  • 打赏
  • 举报
回复
看来讨论讨论还是很有用的呀!
csf 2011-08-17
  • 打赏
  • 举报
回复
谢谢大家了,已经明白了!呵呵!
fontlose 2011-08-15
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 id19870510 的回复:]
Files saved in the assets/ directory are not given a resource ID, so you can't reference them through the R class or from XML resources. Instead, you can query files in the assets/ directory like a normal file system and read raw data using AssetManager.


这是摘自官方文档, 我不知道阁下指的“资源”是什么

至于你后面的那段cpp实现, 我不知道你想要告诉我什么, 还忘多指教[/Quote]

这段E文说不能通过资源ID来访问,但可以通过AssetManager提供的方法类查询这些文件。

这里说的资源是资源文件,7楼给出的那段代码定义了很多后缀,带这些后缀的资源文件是不会压缩的,在Android 2.3以前的任何压缩的资源的原始大小超过1M将不能从APK中读出,如果你使用AssetManager 或 Resources classes方法来获取InputStream,将抛出java.io.IOException的异常。http://blog.csdn.net/fontlose/article/details/6667508




hijovi 2011-08-15
  • 打赏
  • 举报
回复
一般放资源的。。。。当然可以删掉
DrSmart 2011-08-15
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 id19870510 的回复:]

都没说到点子上, 放 html 一般用在web开发

或许还有其他的用处, 那就不太清楚了
[/Quote]
你这回答真的很雷人,这是放资源的,一般部分格式还压缩呢,给你看下android源码中编译apk时的实现吧


using namespace android;

static const char* kExcludeExtension = ".EXCLUDE";

/* these formats are already compressed, or don't compress well */
static const char* kNoCompressExt[] = {
".jpg", ".jpeg", ".png", ".gif",
".wav", ".mp2", ".mp3", ".ogg", ".aac",
".mpg", ".mpeg", ".mid", ".midi", ".smf", ".jet",
".rtttl", ".imy", ".xmf", ".mp4", ".m4a",
".m4v", ".3gp", ".3gpp", ".3g2", ".3gpp2",
".amr", ".awb", ".wma", ".wmv"
};

/* fwd decls, so I can write this downward */
ssize_t processAssets(Bundle* bundle, ZipFile* zip, const sp<AaptAssets>& assets);
ssize_t processAssets(Bundle* bundle, ZipFile* zip,
const sp<AaptDir>& dir, const AaptGroupEntry& ge);
bool processFile(Bundle* bundle, ZipFile* zip,
const sp<AaptGroup>& group, const sp<AaptFile>& file);
bool okayToCompress(Bundle* bundle, const String8& pathName);
ssize_t processJarFiles(Bundle* bundle, ZipFile* zip);
zhangliang_88 2011-08-15
  • 打赏
  • 举报
回复
学习了~
-droidcoffee- 2011-08-15
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 drsmart 的回复:]

引用 6 楼 id19870510 的回复:

都没说到点子上, 放 html 一般用在web开发

或许还有其他的用处, 那就不太清楚了

你这回答真的很雷人,这是放资源的,一般部分格式还压缩呢,给你看下android源码中编译apk时的实现吧


using namespace android;

static const char* kExcludeExtensio……
[/Quote]

Files saved in the assets/ directory are not given a resource ID, so you can't reference them through the R class or from XML resources. Instead, you can query files in the assets/ directory like a normal file system and read raw data using AssetManager.


这是摘自官方文档, 我不知道阁下指的“资源”是什么

至于你后面的那段cpp实现, 我不知道你想要告诉我什么, 还忘多指教
j_f0001 2011-08-15
  • 打赏
  • 举报
回复
放一些比较小的文件,程序把它当作本地文件使用,因为他是当作程序的本地文件使用,所以文件不要太大,否则加载时间太长 倒至ANR错误。比如有些固定的数据,如全国省市、性别等都可以存在asset里面当作资源使用。跟其它的目录最在的区别就是此文件夹下的文件不会生成ID
-droidcoffee- 2011-08-15
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 drsmart 的回复:]

引用 6 楼 id19870510 的回复:

都没说到点子上, 放 html 一般用在web开发

或许还有其他的用处, 那就不太清楚了

你这回答真的很雷人,这是放资源的,一般部分格式还压缩呢,给你看下android源码中编译apk时的实现吧


using namespace android;

static const char* kExcludeExtensio……
[/Quote]

弱弱的问一句 我回答的怎么雷人了?
-droidcoffee- 2011-08-15
  • 打赏
  • 举报
回复
[Quote=引用 18 楼 drsmart 的回复:]
引用 11 楼 id19870510 的回复:


这是摘自官方文档, 我不知道阁下指的“资源”是什么

至于你后面的那段cpp实现, 我不知道你想要告诉我什么, 还忘多指教



这段cpp,表示assets目录存放的格式很多,部分格式会压缩打包的,比如上面的格式由于已经压缩就不需要再压缩了,这段回复是相对于 6楼这句“都没说到点子上, 放 html 一般用在web开发的”,比……
[/Quote]

好吧, 学习了, 我表示鸭梨很大
解未知数 2011-08-15
  • 打赏
  • 举报
回复
学习了..............
DrSmart 2011-08-15
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 id19870510 的回复:]


这是摘自官方文档, 我不知道阁下指的“资源”是什么

至于你后面的那段cpp实现, 我不知道你想要告诉我什么, 还忘多指教

[/Quote]

这段cpp,表示assets目录存放的格式很多,部分格式会压缩打包的,比如上面的格式由于已经压缩就不需要再压缩了,这段回复是相对于 6楼这句“都没说到点子上, 放 html 一般用在web开发的”,比如我们做的来电归属地数据库,就是放到assets目录的,还有就是游戏中的部分资源文件,比如mp3音乐等等
DrSmart 2011-08-15
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 id19870510 的回复:]

都没说到点子上, 放 html 一般用在web开发

或许还有其他的用处, 那就不太清楚了

[/Quote]

呵呵,你的这句“都没说到点子上, 放 html 一般用在web开发”,1楼和3楼,说的已经到点子上了,哈哈
加载更多回复(9)

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧