I'm trying to plug in some Web UI / Javascript code into my app from chrome plugin apps.
Part of what the Javascript does is reading in some translation files (I don't want to change the method it uses to do this too much)
To do this I furnished the Javascript with the ability to read the contents of files in the assets folder for parsing through use of a Javascript interface method which takes a file name and returns the contents of the file as a String.
Unfortunately, this is throwing an exception, whose "message" is the file name I'm passing in. I have no idea therefore why this exception is being thrown:
public String getFileContents(String file) {
String fileContents = "";
try {
AssetManager assetManager = mContext.getAssets();
InputStream inputStream = assetManager.open(file);
BufferedReader r = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder total = new StringBuilder();
String line;
while ((line = r.readLine()) != null) {
total.append(line);
}
fileContents = total.toString();
} catch (IOException e) {
Log.e("IOException", e.getMessage());
Log.e(e);
}
return fileContents;
}
The exception given is below... Can anyone give me a clue as to why this file isn't being opened correctly?
04-11 10:22:12.233: E/Exception(4829): _locales/en/messages.json. android.content.res.AssetManager.openAsset(Native Method)
04-11 10:22:12.233: E/Exception(4829): android.content.res.AssetManager.open(AssetManager.java:316)
04-11 10:22:12.233: E/Exception(4829): android.content.res.AssetManager.open(AssetManager.java:290)
04-11 10:22:12.233: E/Exception(4829): com.test.decatur.object.CoreModInterface.getFileContents(CoreModInterface.java:51)
04-11 10:22:12.233: E/Exception(4829): com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
04-11 10:22:12.233: E/Exception(4829): com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:27)
04-11 10:22:12.233: E/Exception(4829): android.os.Handler.dispatchMessage(Handler.java:102)
04-11 10:22:12.233: E/Exception(4829): android.os.Looper.loop(Looper.java:136)
04-11 10:22:12.233: E/Exception(4829): android.os.HandlerThread.run(HandlerThread.java:61)