I am testing something.
I created assets folder in packages/apps/Camera/ and added the test.txt file in the folder.
But when I accessed the file in the onCreate() method according the following code fragment, I found I can't get the file.
File file = new File("/assets/test.txt");
BufferedReader reader = null;
try {
Log.v("jerikc","read the file");
reader = new BufferedReader(new FileReader(file));
String tempString = null;
int line = 1;
while ((tempString = reader.readLine()) != null) {
Log.v("jerikc","line " + line + ": " + tempString);
line++;
}
reader.close();
} catch (IOException e) {
Log.v("jerikc","exception");
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
The log were :
V/jerikc (3454): read the file
V/jerikc (3454): exception
I think I add the wrong path.("/assets/test.txt") . So what's the right path?
Some other informations:
Where my real code is a Util Class, there isn't the context. If I add the context, the code structure will have a big change.
Thanks.