'How to read choosen file content in Cordova app?
I want to perform the below task in my Cordova android app
- Give the user the ability to choose any txt file from his device.
- Then the file content I need to read in my app
- Modify file content and store it in another txt file
For Choosing text file I have used
cordova-plugin-filechooser
And written code as below
fileChooser.open(function (uri) {
alert(uri);
});
Which correctly opens the dialog to choose a file. After choosing the file I am getting uri as below
content://com.android.providers.downloads.documents/document/446
Now how I should read the file content? I am also using
cordova-plugin-file
I have checked code for cordova-plugin-file and we need to use fileEntry
, how should I accomplish that?
Solution 1:[1]
You could use instead cordova-plugin-filepath then do
let path = FilePath.resolveNativePath('content://...', successCallback, errorCallback);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Eric |