2

Im developing an app using Andriod Studio and I´ve got some problemns accessing my assets subfolders. When I try to access a file, say file1, in the assets root folder, like this

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(); } 

I get the text successfuly. But when I change "file1.txt" to "sub\file2.txt" I get an file not found execption.

Anyone has any idea what is going on? Am I missing something?

Thanks!

1 Answer 1

2

Android is linux based - use a forward slash not backslash. So, sub/file2.txt

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.