This question is locked. New answers and comments are not allowed.
Now i am using below file concept in jquery mobile, this working fine only in android device not in iphone
is any possible to store file inside our App not in sdcard (android and iphone)?
/* Create Local Xml Files */
function store_LocalXML() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
function gotFS(fileSystem) {
// create dir
fileSystem.root.getDirectory("folderName", {
create: true,
exclusive: false
}, gotDirEntry, fail);
}
function gotDirEntry(dirEntry) {
// create file
dirEntry.getFile("filename", {
create: true,
exclusive: false
}, gotFileEntry, fail);
}
function gotFileEntry(fileEntry) {
fileEntry.createWriter(gotFileWriter, fail);
}
function gotFileWriter(writer) {
writer.onwrite = function (evt) {
// alert("write completed");
};
writer.write(stored_Content);
writer.abort();
}
function fail(error) {
alert(error.code);
}
is any possible to store file inside our App not in sdcard (android and iphone)?
/* Create Local Xml Files */
function store_LocalXML() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
function gotFS(fileSystem) {
// create dir
fileSystem.root.getDirectory("folderName", {
create: true,
exclusive: false
}, gotDirEntry, fail);
}
function gotDirEntry(dirEntry) {
// create file
dirEntry.getFile("filename", {
create: true,
exclusive: false
}, gotFileEntry, fail);
}
function gotFileEntry(fileEntry) {
fileEntry.createWriter(gotFileWriter, fail);
}
function gotFileWriter(writer) {
writer.onwrite = function (evt) {
// alert("write completed");
};
writer.write(stored_Content);
writer.abort();
}
function fail(error) {
alert(error.code);
}
7 Answers, 1 is accepted
0

David Silveria
Top achievements
Rank 1
answered on 16 Dec 2013, 01:47 PM
Do you get any errors on iOS, have you tried debugging the code to see what goes wrong? The File sample works on both Android and iOS, so I would check for discrepancies.
0

Deepan
Top achievements
Rank 1
answered on 18 Dec 2013, 10:38 AM
"File Sample" coding is working well , but i need directory to store the files. So i used this type of coding,
in "File Sample" coding datas are appending in files, i need data should be overwrite or file should be overwrite .
In my coding
"writer.write(stored_Content);"
this line is working fine to create a file at a first time("test.xml"), but this line is not working after deleted this file and recreate a same file name("test.xml") .
i wish to delete and create same filename "test.xml" at same time.
function delete_localXML() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, delete_process, fail);
}
function delete_process(fileSystem) {
// create dir
fileSystem.root.getDirectory("HEMS", {
create: true,
exclusive: false
}, gotDirEntry_delete, fail);
}
function gotDirEntry_delete(dirEntry) {
// create file
dirEntry.getFile(delete_FileName, {
create: true,
exclusive: false
}, deleteFile, fail);
}
function deleteFile(fileEntry) {
fileEntry.remove(function() {
console.log("File Removed");
});
}
in "File Sample" coding datas are appending in files, i need data should be overwrite or file should be overwrite .
In my coding
"writer.write(stored_Content);"
this line is working fine to create a file at a first time("test.xml"), but this line is not working after deleted this file and recreate a same file name("test.xml") .
i wish to delete and create same filename "test.xml" at same time.
function delete_localXML() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, delete_process, fail);
}
function delete_process(fileSystem) {
// create dir
fileSystem.root.getDirectory("HEMS", {
create: true,
exclusive: false
}, gotDirEntry_delete, fail);
}
function gotDirEntry_delete(dirEntry) {
// create file
dirEntry.getFile(delete_FileName, {
create: true,
exclusive: false
}, deleteFile, fail);
}
function deleteFile(fileEntry) {
fileEntry.remove(function() {
console.log("File Removed");
});
}
0
Hi Deepan,
I believe the file deletion and creation in your code snippet are mixed up. The steps for replacing a file should be as follows:
Further, you can check the Cordova File Api documentation where you will find more information and some good usage examples about the api.
I hope this helps.
Regards,
Kaloyan
Telerik
You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
Looking for tips & tricks directly from the Icenium team? Check out our blog!
Share feedback and vote for features on our Feedback Portal.
I believe the file deletion and creation in your code snippet are mixed up. The steps for replacing a file should be as follows:
- Get directory (success/fail);
- Get file (success/fail);
- Delete file (success/fail);
- Create file (success/fail).
I reworked your code like this:
function
delete_process(fileSystem) {
// You should get the directory or create it if it doesn't exist
// and on success call the gotDirEntry fucntion.
fileSystem.root.getDirectory(
"HEMS"
, {
create:
true
,
exclusive:
false
}, gotDirEntry, fail);
}
function
gotDirEntry(dirEntry) {
// You do not need to create the file as it should already exist in the system.
// You should only get the file and on success call the deleteFile function.
// On fail you should directly create the new file.
dirEntry.getFile(delete_FileName, {
create:
false
,
exclusive:
false
}, deleteFile, CreateDirEntry);
}
function
deleteFile(fileEntry) {
// First we delete the file and on success we call the CreateDirEntry function.
fileEntry.remove(CreateDirEntry, fail);
}
function
CreateDirEntry(dirEntry) {
// Finally you need to create the new file again in the according dir.
dirEntry.getFile(delete_FileName, {
create:
true
,
exclusive:
false
}, success, fail);
}
Further, you can check the Cordova File Api documentation where you will find more information and some good usage examples about the api.
I hope this helps.
Regards,
Kaloyan
Telerik
You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
Looking for tips & tricks directly from the Icenium team? Check out our blog!
Share feedback and vote for features on our Feedback Portal.
0

Deepan
Top achievements
Rank 1
answered on 23 Dec 2013, 05:41 AM
Thank u for your response
Your code is perfectly working only in Android. but same error occur in IPhone. file creation not worked after delete functionality.
i got solution for this,
// test.xml
delete_localXML();
// check file availability using ajax
$.ajax({
type: 'GET',
url: filePath,
dataType: 'html',
success: function (data) {
// File Available
},
error: function (e) {
// File not Available
// test.xml
store_LocalXML();
},
});
this coding working perfectly in Iphone and also Android, what i expected
Your code is perfectly working only in Android. but same error occur in IPhone. file creation not worked after delete functionality.
i got solution for this,
// test.xml
delete_localXML();
// check file availability using ajax
$.ajax({
type: 'GET',
url: filePath,
dataType: 'html',
success: function (data) {
// File Available
},
error: function (e) {
// File not Available
// test.xml
store_LocalXML();
},
});
this coding working perfectly in Iphone and also Android, what i expected
0
Hi Deepan,
Thank you for sharing this solution.
Regards,
Iva Koevska
Telerik
You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
Looking for tips & tricks directly from the Icenium team? Check out our blog!
Share feedback and vote for features on our Feedback Portal.
Thank you for sharing this solution.
Regards,
Iva Koevska
Telerik
You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
Looking for tips & tricks directly from the Icenium team? Check out our blog!
Share feedback and vote for features on our Feedback Portal.
0

Deepan
Top achievements
Rank 1
answered on 28 Jan 2014, 04:12 PM
Hi
Am getting issue in Deleting and overwriting file concept in Iphone
One time delete method is working, for second time this is not working properly.
While deleting
fileEntry.remove(function() {
console.log("File Removed");
});
this method is not working in iphone .
Am not getting any error ,in log am getting "File Removed", but files are not deleting .
Am getting issue in Deleting and overwriting file concept in Iphone
One time delete method is working, for second time this is not working properly.
While deleting
fileEntry.remove(function() {
console.log("File Removed");
});
this method is not working in iphone .
Am not getting any error ,in log am getting "File Removed", but files are not deleting .
0
Hi Deepan,
You can try debugging directly on the device to figure out what goes wrong: Debug on iOS Device.
Regards,
Steve
Telerik
You can try debugging directly on the device to figure out what goes wrong: Debug on iOS Device.
Regards,
Steve
Telerik
Icenium is now Telerik AppBuilder, and is part of the Telerik Platform. For more information on the new name, and to learn more about the Platform, register for the free online keynote and webinar on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT)