Android filewrite error 9

956 views
Skip to first unread message

VoVa Vc

unread,
Mar 25, 2012, 11:48:22 AM3/25/12
to phonegap
Hello everybody.
I have a very strange problem. My app needs to write a file, but
always gets the same error:
File error 9 (Invalid modification)
here is the code:
variables Lenapath & currentPos are paths to file
filenameS is variable that contains name of file, for examle
"text.txt"
function saveSCode(){
if(Lena==1){
window.resolveLocalFileSystemURI(Lenapath, gotFileEntryW, fail);
}
else{
var currentPos=$('#currentD').attr('name')
var currentName=$('#currentD').attr('data-entry')
currentPos=currentPos.replace(currentName, "")
window.resolveLocalFileSystemURI(currentPos, gotFileEntryW, fail);
}
}
function failing(error){
alert('Failing with error code '+error.code);
}
function gotFileEntryW(fileEntry){
var filenameS='"'+$("#filename").val()+'.'+$("#dim").val()+'"'
fileEntry.getFile(filenameS, {create: true, exclusive: true},
gotFileEntrySW, failing);//here is the error
}
function gotFileEntrySW(fileEntry){
fileEntry.createWriter(gotFileWriterW, fail);
}
function gotFileWriterW(writer) {
writer.write($("#codeText").val());
alert("contents of file now "+$("#codeText").val());
}
function fail(error) {
alert('Error code '+error.code);
}
There are also a console log error on app start:
03-25 19:24:42.276: I/Web Console(18224): JSCallback Error: Request
failed. at file:///android_asset/www/cordova-1.5.0.js:4244
I had googled this problem, but find out nothing. Please help with
this trouble.

Simon MacDonald

unread,
Mar 26, 2012, 10:22:30 AM3/26/12
to phon...@googlegroups.com
That's a weird one, getFile should not throw that error.

Make sure you...

a) Have a SD card mounted.
b) have the permission android.permission.WRITE_EXTERNAL_STORAGE in your Manifest file.

Simon Mac Donald
http://hi.im/simonmacdonald



--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en

For more info on PhoneGap or to download the code go to www.phonegap.com

VoVa Vc

unread,
Mar 26, 2012, 2:49:57 PM3/26/12
to phonegap
It realy was needed only to add a premission, thank you for your help
Reply all
Reply to author
Forward
0 new messages