I'm developing an application that will be deployed on iPad.
In the application I have a local sqlite database that has to be synchronised with the online version.
At application startup I check if the sqlite database is synchronised, if not I download it and overwrite the old database.
When I test the application inside flash builder there aren't any errors, but when deploying the application to iPad and run the debug I get this error when the application makes attempt to overwrite the sqlite database file:
Error: Error #3001: File or directory access denied. at flash.filesystem::FileStream/open() at Function/dial.model:Corsi/private:downloadDbComplete/dial.model:onCloseDb()[corso/src/dial/model/Corsi.as:133] at flash.data::SQLConnection/internalClose() at flash.data::SQLConnection/close() at dial.model::Corsi/downloadDbComplete()[corso/src/dial/model/Corsi.as:141] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at flash.net::URLLoader/onComplete()
Before overwrite the file I close the connection to the sqlite database.
To overwrite the file i use this code:
var dbString:String=File.applicationDirectory.nativePath.toString() dbString+="/assets/db/dial_mobile.sqlite" var db:File=new File(dbString) var stream:FileStream=new FileStream() stream.open(db,FileMode.WRITE) stream.writeBytes(e.target.data) //e.target.data is the sqlite file download through the urloader class stream.close()
This error is really driving me crazy.
Has anyone encountered a similar error?
Any ideas on how to let it work?
Thanks in advance
I also tried to delete the file, but when i call db.deleteFile() the debugger traces that "is not a file"....
By doing some further test I achieved that on iOs you can't write into the application directory, but in the Documents directory you can.
So, i switched File.applicationDirectory in File.documentsDirectory
Hope this might help someone else