tj1010 wrote:They use wrappers for W3 stuff [...]
... and that's my problem. After deploying the project to a mobile device, the so called persistent files are gone.
Here is a little snippet to demonstrate that effect. Create an Android-App and deploy it to a device. Click on 'Create' and several times on 'Append'. After a click on 'Read' several lines are printed out in the debug-window. After deloying the code again, the 'log.txt' is gone.
Code: Select all
Enumeration
#frmMain
EndEnumeration
Enumeration
#frmMain_cmdCreate
#frmMain_cmdAppend
#frmMain_cmdRead
EndEnumeration
Procedure cmdCreateEvent()
! function create_errorHandler(e) { spider.debug.Print( 'create file error: ', e.name, ', ', e.message ); }
! function create_onInitFs(fs) {
! fs.root.getFile('log.txt', {create: true}, function(fileEntry) {
! fileEntry.createWriter(function(fileWriter) {
! fileWriter.onwriteend = function(e) { spider.debug.Print('Create completed.'); };
! fileWriter.onerror = function(e) { spider.debug.Print('Create failed: ' + e.toString()); };
! var blob = new Blob(['filecreated\n'], {type: 'text/plain'});
! fileWriter.write(blob);
! }, create_errorHandler);
! }, create_errorHandler);
! }
! var requestedBytes = 1024*1024*280;
!
! navigator.webkitPersistentStorage.requestQuota (
! requestedBytes, function(grantedBytes) {
! window.webkitRequestFileSystem(PERSISTENT, grantedBytes, create_onInitFs, create_errorHandler);
! },
! function(e) { spider.debug.Print('Error', e); }
! );
EndProcedure
Procedure cmdAppendEvent()
! function append_errorHandler(e) { spider.debug.Print('write file error: ', e.name, ', ', e.message); }
! function append_onInitFs(fs) {
! fs.root.getFile('log.txt', {create: false}, function(fileEntry) {
! fileEntry.createWriter(function(fileWriter) {
! fileWriter.onwriteend = function(e) { spider.debug.Print('Append completed.'); };
! fileWriter.onerror = function(e) { spider.debug.Print('Append failed: ' + e.toString()); };
! fileWriter.seek(fileWriter.length); // Start write position at EOF.
! var blob = new Blob(['Lorem Ipsum\n'], {type: 'text/plain'});
! fileWriter.write(blob);
! }, append_errorHandler);
! }, append_errorHandler);
! }
! var requestedBytes = 1024*1024*280;
!
! navigator.webkitPersistentStorage.requestQuota (
! requestedBytes, function(grantedBytes) {
! window.webkitRequestFileSystem(PERSISTENT, grantedBytes, append_onInitFs, append_errorHandler);
! },
! function(e) { spider.debug.Print('Error', e); }
! );
EndProcedure
Procedure cmdReadEvent()
! function read_errorHandler(e) { spider.debug.Print('write file error: ', e.name, ', ', e.message); }
! function read_onInitFs(fs) {
! fs.root.getFile('log.txt', {}, function(fileEntry) {
! fileEntry.file(function(file) {
! var reader = new FileReader();
! reader.onloadend = function(e) { spider.debug.Print(this.result); };
! reader.readAsText(file);
! }, read_errorHandler);
! }, read_errorHandler);
! }
! var requestedBytes = 1024*1024*280;
!
! navigator.webkitPersistentStorage.requestQuota (
! requestedBytes, function(grantedBytes) {
! window.webkitRequestFileSystem(PERSISTENT, grantedBytes, read_onInitFs, read_errorHandler);
! },
! function(e) { spider.debug.Print('Error', e); }
! );
EndProcedure
OpenWindow(#frmMain, 0, 0, 0, 0, "Test", #PB_Window_Background)
ButtonGadget(#frmMain_cmdCreate, 10, 10, 300, 50, "Create file")
ButtonGadget(#frmMain_cmdAppend, 10, 70, 300, 50, "Append text")
ButtonGadget(#frmMain_cmdRead, 10, 130, 300, 50, "Read file")
BindGadgetEvent(#frmMain_cmdCreate, @cmdCreateEvent())
BindGadgetEvent(#frmMain_cmdAppend, @cmdAppendEvent())
BindGadgetEvent(#frmMain_cmdRead, @cmdReadEvent())
Greetings ... Peter (now coding a cordova-wrapper)