Building a Directory with Cordova Application

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.

Answer №1

Did you receive a request to provide the necessary authorizations when attempting to save the document? You should have encountered a window similar to this:

https://i.sstatic.net/CNmWR.png

If this did not happen, it is likely due to using an outdated plugin version. Alternatively, there may be an issue with your code that I am unable to assist with, apologies for any inconvenience.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can you explain the distinction between using angular.copy() and simply using an assignment (=) to assign values

When a button is clicked, I want to assign certain values using the event parameter. Here is the code: $scope.update = function(context) { $scope.master = context; }; The $scope.master has been assigned the values of user. Recently, I came across th ...

Distinguish the components of a standard union in TypeScript

I am looking to incorporate the following feature: const foo = <S>(newState: S | ((prevState: S) => S)) => {...} This function should accept either a new state of type S, or a function that generates the new state from the old state. In my i ...

Switching back and forth between two different numbers with the help of React.useState hooks

Can someone help me with the logic using React.useState hooks? I'm trying to toggle the "volume" option in the state of the "PlayOn" object between 0 and 0.75. I am not very experienced with React. I need help with the function logic for soundChange ...

The JavaScript code functions perfectly when inputted directly into the Chrome Developer Console and executed, however, encounters an error when run from the index.html file using the src tag

I am starting from scratch with web development. On my page, there is an image carousel with two buttons for navigating between different images. When I use Brackets live preview to test my website, I encounter the following error message. Uncaught TypeErr ...

How do I retrieve the row count of a table after applying filters in Ant Design?

While working with the Table component from Ant-design to search, filter, and sort a large dataset, an issue arose with the "Select all Data" functionality. For instance, clicking on the checkbox at the top of the table only selects the rows currently dis ...

Discovering the presence of a NAN value within a JSON string

Consider the following scenario: I have a function that receives jsonData in JSON format, and I want to validate the variable jsonData to check for NaN. How can I achieve this? function save() { var jsonData = getEnteredValue(); $.ajax({ ...

Generating dynamic anchor tags in Vue.JS

I have a JavaScript object that I want to convert into HTML elements and display it in Vue.js. So far, my approach has been to convert the object into strings representing HTML elements and then add them to the template. However, even though this method di ...

Tips for reaching a node.js application deployed on Heroku

Trying to deploy my node.js app to Heroku has been a challenge. Despite watching various tutorials and reading the documentation, I'm stuck on how to send and receive data from the hosted node.js app. The communication between my webpage and the node. ...

Is there a workaround for Angular ui-sref param removing spaces?

Looking for help with an anchor tag: <a ui-sref="view({id:{{ id }}})" data-toggle="tooltip" data-placement="top" title="View Details"><i class="fa fa-search-plus fa-2x icon-color"></i></a> The issue I'm facing is with the id ...

Guide to transferring shortcode parameter values to Javascript/Ajax interactions

I have developed a custom contact form shortcode that is processed using ajax. The shortcode includes a parameter to specify the email address where the messages should be sent. This allows me to use different email accounts depending on the specific form. ...

The Model Viewer module is unable to load the three-dimensional model

Attempting to incorporate a 3D model into my website using the modelviewer library, but encountering difficulties in loading the file as shown below: Just to note, I am utilizing github pages with a custom domain from godaddy which may be contributing to ...

Hold tight for the response from the AngularJS factory request

In my Rails application, I am incorporating Angular. The code snippet below shows an API request being made and the code in the .run function being executed. Sometimes, the API response is still pending when the code is executed. This leads to issues with ...

Using JavaScript to pass the href attribute value

On my HTML page, there are multiple links that reload the page when clicked. I want to capture the href value of each link the user clicks and store it in a variable called xhash: Here is the HTML: <a href='#taba' id='passid'>Li ...

How selection.join behaves when every node contains child elements

I have been following the amazing tutorial on to learn more about the join paradigm. Everything was working fine until I tried to make each node more complex by adding a group with text inside. The main group gets updated, but the child one does not. Sn ...

Is there a way to specify to a JavaScript variable that it must have a defined value upon creation?

getPersonneById(id: number): Personne{ const personne = this.personnes.find( personne => { return personne.id == id; }); return personne; } An error message is displayed: Unable to assign type 'Person | undefined' to type &a ...

What are the advantages of combining a library (using Rollup or Webpack) instead of simply transpiling it with Babel?

When developing a library in JavaScript, what are the benefits of using tools like Rollup or Webpack for bundling rather than just transpiling with Babel? One potential advantage could be that by bundling, you ensure that your dependencies are packaged eff ...

What is the best way to leverage a webbrowser control for design purposes while keeping the functionality in C#?

Observing some apps, it seems they utilize HTML/CSS/Javascript for styling - a much simpler approach compared to crafting the same thing natively. However, these apps have their logic written in C#. Sadly, I am clueless on connecting the two. Research yiel ...

Issue with conditional comment in IE 8 not functioning as expected

Struggling with changing the SRC attribute of my iFrame specifically for users on IE 8 or older. This is the code I have written: <script> var i_am_old_ie = false; <!--[if lte IE 8]> i_am_old_ie = true; <![endif]--> </script> ...

Issues with Angular 5 components not functioning properly

I am experimenting with a way to show/hide a div based on a boolean value from an observable. After looking at the second answer in this Stack Overflow thread, I implemented the following code snippet that retrieves the document body width and uses it in a ...

XPath Selector in Puppeteer version 22.x

Despite poring over the latest Puppeteer v22.x documentation on XPath, I am still struggling to grasp how to effectively utilize XPath in Puppeteer 22.x. My goal is to click on an element that contains the text 'Next'. Here's the HTML snipp ...