I am using a cord-ion structure to create an application. I am new to iOS or iPhone in my requirement, I have to read the file in the application. I am reading a file in an Android application, but the same code shows an error (code: 5).
I follow the types of code:
in android:
$cordovaFile.writeFile(( 'user.json', data, {'append':false} )).then(function(result) { alert('file created.'); alert(JSON.stringify(result)); }, function(err) {
I can create files, write, read data and delete a file, but on an ios phone I cannot create a file using the same code.
on iPhone:
var data = {"user":{"name":"errer","email":" sdsdff@gmail.com ","username":"sdfsdfsd"}}; $cordovaFile.writeFile(( 'user.json', data, {'append':false} )).then(function(result) {
I just change my directory: cordova.file.cacheDirecotry / cordova.file.applicationDirectory
$cordovaFile.createFile(( cordova.file.cacheDirecotry+'user.json', true )).then(function(result) {
the whole way of getting errors, like code: 12 or code: 5
please help me solve this problem or give me an idea to get the path to the application file.
source share