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实现, 我不知道你想要告诉我什么, 还忘多指教
呵呵,你的这句“都没说到点子上, 放 html 一般用在web开发”,1楼和3楼,说的已经到点子上了,哈哈
这段cpp,表示assets目录存放的格式很多,部分格式会压缩打包的,比如上面的格式由于已经压缩就不需要再压缩了,这段回复是相对于 6楼这句“都没说到点子上, 放 html 一般用在web开发的”,比如我们做的来电归属地数据库,就是放到assets目录的,还有就是游戏中的部分资源文件,比如mp3音乐等等
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);
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实现, 我不知道你想要告诉我什么, 还忘多指教
这段E文说不能通过资源ID来访问,但可以通过AssetManager提供的方法类查询这些文件。 这里说的资源是资源文件,7楼给出的那段代码定义了很多后缀,带这些后缀的资源文件是不会压缩的,在Android 2.3以前的任何压缩的资源的原始大小超过1M将不能从APK中读出,如果你使用AssetManager 或 Resources classes方法来获取InputStream,将抛出java.io.IOException的异常。http://blog.csdn.net/fontlose/article/details/6667508
首先说一下“资源"(文件)
我个人理解,所谓”资源“指的是res目录下的file, 也就是有ID,并且可以通过context.getResources() 访问的file
而assets目录中的就是普通的file而已
。。
至于楼上几位把 assets 中的理解为 "资源" 那我也无话可说的,。 或许是我理解错了
呵呵,你的这句“都没说到点子上, 放 html 一般用在web开发”,1楼和3楼,说的已经到点子上了,哈哈
这段cpp,表示assets目录存放的格式很多,部分格式会压缩打包的,比如上面的格式由于已经压缩就不需要再压缩了,这段回复是相对于 6楼这句“都没说到点子上, 放 html 一般用在web开发的”,比如我们做的来电归属地数据库,就是放到assets目录的,还有就是游戏中的部分资源文件,比如mp3音乐等等
什么web html ..胡说八道
别告诉我你写web的时候不用assets