I’m using NSB App Studio to develop an Android application. I have a binary file that has the datum transformation grid in binary format to Shift coordinates from GCS NAD 83 (2011) to WGS 84. I need to include that file and access it from within my app at runtime. I’m not sure how to get it included.
There are a lot of possible answers to the question, depending on the specifics. Here’s the most up to date:
It sounds like you could include the file in your project. To so, put it in the main folder of your app, then add the filename to requiredFiles in Project Properties. It will then get installed with everything else.
You can then access it with code something like this:
async function downloadFile() {
let response = await fetch("/sample.txt");
if (response.status != 200) {
throw new Error("Server Error");
}
// Read response stream as text
let text_data = await response.text();
return text_data;
}
// Usage
downloadFile()
.then(text_data => {
txtData.text = text_data;
})
.catch(e => {
alert(e.message);
});
I do not see requiredFiles in the project properties. I’ve tried putting a reference to it in extraFiles but had no success.
You’re correct - it should have been extraFiles.
What happened when you did that? What shows up in the Console?
Found my problem. I had the file in folder one level down from the project folder. Once I moved it to the project folder it read it.
Thanks for your help
Could you post your final code, please? I have had similar problems.
Oh, that would be great for me too. It’s not working for me yet either. Thanks!