带有子文件夹的 Android 资产 [英] Android Assets with sub folders

查看:33
本文介绍了带有子文件夹的 Android 资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

InputStream myInput = myContext.getAssets().open("MyFolder/" + "MyFile.db3");

我在上面的子文件夹中的资产文件夹中有一个文件.但是它没有得到文件,有没有一种特殊的方法可以在assets文件夹中指定一个子文件夹?

I have a file in the assets folder in a sub folder as above. It doesn't get the file though, is there a special way to specify a sub folder in the assets folder?

伊恩

推荐答案

子文件夹有误.
此代码在 1.5 上运行良好(对于位于 assets 中的 sub 文件夹下的文件 sample.txt):

was wrong about subfolders.
This code works just fine on 1.5 (for a file sample.txt placed under sub folder in assets):

InputStream is = getAssets().open("sub/sample.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line = null;
while ((line = br.readLine()) != null) {
    Log.e("wtf", line);
}
br.close();

你确定你的名字正确吗?

Are you sure you've got the names right?

这篇关于带有子文件夹的 Android 资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆