I am currently in the process of developing a Cordova App on my own and I'm facing an issue with creating a new folder to save images in the internal storage of the phone. Despite reading various online articles, I have not been successful in finding a solution that works for me.
Below is the code snippet that I am using within the OnDeviceReady event, however, it's not yielding the desired results:
var new_directory = 'TEST';
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
fileSystem.root.getDirectory(new_directory, { create: true }, function (file) {
alert("got the file: "+ file.name + ', ' + file.fullPath);
});
}, function(error) {
alert("can't even get the file system: " + error.code);
});
In my attempt to debug, I also tried to display an alert for:
cordova.file
However, it showed as undefined. Even when trying basic file request statements, they are not functioning properly.
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, alert('success'), alert('failed'));
Furthermore, none of the remaining JavaScript code seems to work when the above-mentioned code is included.
If anyone has any insights or solutions, please assist me in resolving this issue. Your help is greatly appreciated.