Reputation: 423
I can't read file first time after saving file. -But when i restart the app i can read file. -And I set "Application supports iTunes file sharing", i can read file first time.
//File save
this.file.writeFile(filedir,'sample.txt','hellow owlrd')
.then((data)=>{
this.viewCtrl.dismiss();
}).catch(err=>
{
alert('ff'+JSON.stringify(err));
});
//File Read
var filedir = this.file.documentsDirectory ;
this.file.listDir(filedir,'recordtext').then((files)=>
{
var i =0 ;
for( let myfile of files){
this.file.readAsText(filedir,myfile.fullPath.substr(1)).then((contents)=>{
this.pushArray.push(this.getSubStr(contents));
this.txtNames.push(myfile.fullPath.substr(1));
})
}
});
It seems that close file not work well. I don't know the reason correctly. Please help.
Upvotes: 1
Views: 698
Reputation: 423
In the index.html
I moved
before
<script src="build/polyfills.js"></script>
<script src="cordova.js"></script>
And the problem is solved.
Upvotes: 4