Access the Documents file with Cordova.
Access the Documents file with Cordova.
Good morning,
On Android, can it access the Documents file with Cordova.
If so, how to do it?
THANKS
On Android, can it access the Documents file with Cordova.
If so, how to do it?
THANKS
Re: Access the Documents file with Cordova.
I don't remember which plugin is necessary (not all, probably the first one), but in my app I was imported these 3:
On the github of each plugin you can see JS examples of use:
https://github.com/apache/cordova-plugin-file
Code: Select all
Import "cordova plugin add cordova-plugin-file"
EndImport
Import "cordova plugin add cordova-plugin-filepath"
EndImport
Import "cordova plugin add cordova-plugin-filechooser"
EndImport
https://github.com/apache/cordova-plugin-file
Re: Access the Documents file with Cordova.
Good morning,
Thank you but you would not have an example of use with Siperbasic because I do not see how to do
THANKS
Thank you but you would not have an example of use with Siperbasic because I do not see how to do
THANKS
Re: Access the Documents file with Cordova.
I checked my app and this is how I access Documents (or others) to load a text file (no Cordova needed).
Try if this works for you:
Try if this works for you:
Code: Select all
EnableExplicit
Enumeration
#Window
#ButtonGadget
#TextGadget
EndEnumeration
CloseDebugOutput()
Procedure ChooseFileEvent()
Define nombre.s, textoArchivo.s
EnableJS
function cargarArchivo(callback) {
var inputArchivo = document.createElement('input');
inputArchivo.type = 'file';
inputArchivo.accept = '.*';
inputArchivo.style.display = 'none';
document.body.appendChild(inputArchivo);
inputArchivo.addEventListener('change', function(event) {
var archivo = event.target.files[0];
v_nombre=archivo.name;
if (archivo) {
var lector = new FileReader();
lector.onload = function(e) {
var contenido = e.target.result;
localStorage.setItem("contenido", contenido);
localStorage.setItem("nombre", archivo.name);
callback(null, contenido);
};
lector.onerror = function(error) {
callback(error, null);
};
lector.readAsText(archivo);
}
document.body.removeChild(inputArchivo);
});
inputArchivo.click();
};
cargarArchivo(function(error, contenido) {
if (error) {
console.error('Error al cargar el archivo:', error);
} else {
v_textoarchivo=contenido;
DisableJS
; Your filename is in variable: nombre
; Your content is in variable: textoarchivo
SetGadgetText(#TextGadget,textoArchivo)
EnableJS
}
});
DisableJS
EndProcedure
OpenWindow(#Window, #PB_Ignore, #PB_Ignore, 400, 700, "", #PB_Window_ScreenCentered|#PB_Window_BorderLess)
ButtonGadget(#ButtonGadget, 10, 10, 380, 50, "LOAD TEXT FILE")
TextGadget(#TextGadget,10,70,380,620,"",#PB_Text_Border)
BindGadgetEvent(#ButtonGadget, @ChooseFileEvent())
Re: Access the Documents file with Cordova.
I just tested and unfortunately, it does not work.
I have a blue screen but no display of the window.
By removing the contents of the "Choosefileevent" procedure there is display of the window.
I tested on several smartphones and Android, same result
I have a blue screen but no display of the window.
By removing the contents of the "Choosefileevent" procedure there is display of the window.
I tested on several smartphones and Android, same result
Re: Access the Documents file with Cordova.
I don't know why doesn't work for you
Use : chrome://inspect/#devices on the Chrome browser (PC) and find what is the error on the developer console (F12)
Here is the apk of the code I posted:
https://drive.google.com/file/d/1hNG_64 ... sp=sharing
Use : chrome://inspect/#devices on the Chrome browser (PC) and find what is the error on the developer console (F12)
Here is the apk of the code I posted:
https://drive.google.com/file/d/1hNG_64 ... sp=sharing
Re: Access the Documents file with Cordova.
Your apkfunction perfectly.
So comes from my home
I use the Demo version of Spiderbasic but I have no problem with the creation of other APK.
Your APK is a little over 7mm, mine 4.8MB
So comes from my home
I use the Demo version of Spiderbasic but I have no problem with the creation of other APK.
Your APK is a little over 7mm, mine 4.8MB
Re: Access the Documents file with Cordova.
I think that could be the problem.
Re: Access the Documents file with Cordova.
Could you tell me if you put special parameters when creating the APK
I have forgotten guidelines
I have forgotten guidelines
Re: Access the Documents file with Cordova.
Nothing special:
https://prnt.sc/CFxm02uMyBhP
https://prnt.sc/CFxm02uMyBhP