【发布时间】:2015-01-21 10:57:06
【问题描述】:
我应该如何从assets 读取文本文件?
我在这里使用片段。
看起来我不能对getAssets(); 使用任何东西,因为然后我得到:Error:(88, 37) error: cannot find symbol method getAssets() 目标是能够读取/写入多个字符串。
例如:
AssetManager assetManager = getAssets();
InputStream inputStream = null;
try {
inputStream = assetManager.open("hello.txt");
}
catch (IOException e){
Log.e("message: ",e.getMessage());
}
我希望能够在一个位置读取值,然后在代码的另一个位置写入值。请帮忙,我很绝望,我在网上找到的都没有工作
【问题讨论】:
-
您需要一个上下文来调用该方法。您可以从片段中调用 getActivity 来获取该上下文。
-
仍然不知道它是如何工作的
标签: android file text fragment assets