where to save a file inside the nativescript project to be able to access it

0

I want to open a file in nativescript, I can open it using the following code:

var openFile = function () {
var FilePath = file.path;
if (FilePath === false) {
    console.log('File Format Not Available');
} else {
    var intent = new android.content.Intent(android.content.Intent.ACTION_VIEW);
    intent.setDataAndType(android.net.Uri.fromFile(new java.io.File(FilePath)), "text/html");
    application.android.currentContext.startActivity(android.content.Intent.createChooser(intent, "Open File..."));
}

};

is an html file by the way, and this code works to open, the problem is that it always gives file error not found. I have already looked in the documentation, but it does not say in which project folder I should put this file I want to open, I researched a lot and saw that I am not the only one having problem with this.

The code to get the file path according to the documentation is:

const fileSystemModule = require("tns-core-modules/file-system");
const file =fileSystemModule.knownFolders.documents().getFile("./Documents/fs.html");

I put the file (fs.html) inside a folder called "Documents" and pasted the folder and several places in the project only to see if it worked (no options ..) and nothing. I also tried currentApp ()

const file =fileSystemModule.knownFolders.currentApp().getFile("./Documents/fs.html");

and nothing ... whenever the application that is called to view the file (html in case) it says the file was not found. would anyone have any idea how to open this html file? Where should I put it? because honestly the nativescript documentation regarding this is bad.

    
asked by anonymous 12.06.2018 / 22:29

0 answers