I need some help to read a resource file in an application.
I have a resource file located in resources/jsonData/jsonResources.xml. The content of the file is the following:
<jsonDataResources>
<jsonData id="arrayB">
[10, 20]
</jsonData>
</jsonDataResources>
Now I want to read this array from the resource file. I do like this:
var array = null;
try {
array = Ui.loadResource(Rez.JsonData.arrayB);
} catch (e instanceof Lang.Exception) {
System.println("Exception: " + e.getErrorMessage);
}
if(array == null){
System.println("The array is null");
} else {
System.println("The array is not null. Size: " + array.size());
}
When I run this on the simulator I get this result:
"The array is not null. Size: 2"
When I upload this to my device (forerunner 230) it crash when it execute. I have added a log file but there is no more information in it. I cant find the exception message in it. The try catch statement don't seem to work at all. I thought I could avoid a crash with it. If I remove the row "array = Ui.loadResource(Rez.JsonData.arrayB);" the application do not crash. In the log file I can then read "The array is null".
Where do I go from here?