Android Java层读取asserts目录中的文件:
//获取asserts/test/目录下的所有文件名称
String test_path = "test";
int currentImg = 0;
String str[] = this.getAssets().list(test_path);
if (currentImg >= str.length){
currentImg = 0;
}
//找下一张图片
while(!str[currentImg].endsWith(".jpg") && !str[currentImg].endsWith(".jpg"))
{
currentImg++; //过滤掉不为图片的
if (currentImg >= str.length){
currentImg = 0;
return -1;
}
}
while(currentImg < str.length)
{
String tempStr = "test/" + str[currentImg];
InputStream is = this.getAssets().open(tempStr);
Bitmap bmp = BitmapFactory.decodeStream(is);
currentImg++;
}
Android JNI层读取asserts目录中的文件:
char* filePathName="1.bin";//1.bin为asserts目录中的
AAssetManager* mManeger = AAssetManager_fromJava(env, assetManager);
AAsset* pAsset = AAssetManager_open(mManeger, filePathName, AASSET_MODE_UNKNOWN);
size_t dataBufferSize = AAsset_getLength(pAsset);
char* pData = new char[dataBuffe

本文介绍了如何在Android应用中,从Java层和JNI层读取assets目录中的文件,详细阐述了两种不同层次的实现方法。
最低0.47元/天 解锁文章
2751

被折叠的 条评论
为什么被折叠?



