1
在使用Andriod Studio開發應用程序時,我有一些問題訪問我的資產子文件夾。 當我試圖訪問一個文件,說文件1,在資產根文件夾,這樣無法訪問資產子文件夾中的文件
AssetManager assetMng = getAssets();
InputStream textoInput;
String path = "file1.txt";
try {
textoInput = assetMng.open(path);
BufferedReader r = new BufferedReader(new InputStreamReader(textoInput));
StringBuilder total = new StringBuilder();
String line;
while ((line = r.readLine()) != null) {
total.append(line);
}
} catch (IOException e){
lista.add("Exception: " + e.toString());
e.printStackTrace();
}
我得到的文本successfuly。但是當我將「file1.txt」更改爲「sub \ file2.txt」時,我得到一個未找到執行文件的文件。
任何人有任何想法是怎麼回事?我錯過了什麼嗎?
謝謝!