Cant read txt file on android device


#1
var documents = fs.knownFolders.documents();
var myFile = documents.getFile("Test_Write.txt");

var written: boolean;
// Writing text to the file.
myFile.writeText("Something")
    .then(function () {
        // Succeeded writing to the file.

        // Getting back the contents of the file.
        myFile.readText()
            .then(function (content) {
                // Successfully read the file's content.
            }, function (error) {
                // Failed to read from the file.
            });
    }, function (error) {
        // Failed to write to the file.
    });

to be able to read the file you to override it first that’s I find from searching and reading documentation the problem on that’s is you need to have content of the file to override it with it but I cant get it because I cant read it any idea or plugin can help read the file without need to override it


#2

I’m able to write and read file with your same code.


#3

yes its work but if you wanna read file you to ovveride it first then read it i dont have content of file to i be able to overide it then read it


#4

you cant only just read file without overide it


#5

I’m sorry man, not really getting what you mean by override it


#6

mean you need to use writeText() to write the file then use readText() to read it but if you have file thats you didnt write with writeText() you want be able to read it and sorry for my english


#7

You should be able to read any file.


#8

thanks man for the help but its still not working its read files on the project directorys but its cant read files from android directory paths l


#9

Can you please be more specific if you are trying to read a particular file. In case if you are trying to read a file from external storage, you have to first obtain the permissions.


#10

i obtain permission and my file path 100% correct the problem is on fs module from whats i read on this https://github.com/NativeScript/NativeScript/issues/3248
you cant only read just file you have to write then read