Issue 1000: Unable to save or generate a file within my application using ionic-native/file in Ionic 2

Currently, I am developing a hybrid app that focuses on localization. The concept involves providing the user with three language options to choose from. To accomplish this, I have set up a node.js server on Bluemix that interacts with a Cloudant NoSQL database. My approach includes comparing the "rev" values in my local JSON file with those on the server. If there is a discrepancy, I need to update the local file accordingly. While I have managed to retrieve the necessary data, I am facing challenges when it comes to writing this data back to the local file. My development environment consists of Cordova and Ionic 2.

public  GetRevFromNode(SelectedLanguage,JsonDataLocal)
    {
        JsonDataLocal.subscribe(val=>{  this.LocJson=val;  })
        this.http.get('https://*********/retriev?ID=\"'+SelectedLanguage+"\"").subscribe( result=>
        { 
           if(this.LocJson['_rev']==result.json().value)
            {
                console.log("The Local JSON is Updated to the latest");
                return ;
            }
            {
                console.log("Updating JSON File for "+SelectedLanguage+".json .......");
                var ob=this.file.readAsText(this.file.applicationDirectory+'www/assets/i18n',"ar.json");
                ob.then(function(val){
                    console.log("ar JSON  = "+val);
                });
                this.file.createFile('file:///android_asset/www',"ess.json",true).catch(val=>{
                    console.log("Can't create because = "+JSON.stringify(val));
                });

   this.file.writeFile('file:///android_asset/www/',"index.html","\"value\":\"Please\"",{replace:true , append:false} ).catch(val=>{
                    console.log("Can't write because ="+JSON.stringify(val));
                console.log("Updating Done ...")
            }
        } );
    }

I attempted to resolve the issue by using this.file.appDirectory but encountered errors. Additionally, I tried making implicit adjustments as demonstrated here.

An error message is displayed:

Uncaught promise [object Object]
Using stringify: {Code:1000}

I can read and check for the existence of files normally; however, creating and writing pose challenges.

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

Is it considered acceptable in React for the value of one state to be determined by another state?

Consider this scenario: state1 tracks the mouseover of clientX and clientY, while state2 retrieves the value from state1 upon clicking. Is this implementation acceptable? const [move,setMove]=useState([]) const [click,setClick]=useState([]) useEffect(() ...

Centralizing images in a Facebook gallery/lightbox during the loading process

Is the image width and height stored in Facebook's gallery database? In typical JavaScript usage, the image width and height cannot be determined until the image is fully loaded. However, on Facebook, images are pre-loaded before being displayed, ens ...

Connecting MVC Model data with AngularJS ModelHere are some strategies for linking data between

Currently, I am utilizing MVC Razor View in combination with AngularJS. Within the controller, I am initializing the UserMaster object and passing it along to the view. Function AddNewUser() As ActionResult Dim objUser As New UserMaster() ...

What is causing the discrepancies in the output between --trace-opt/--trace-deopt and the %GetOptimizationStatus V8 API call?

The results produced by executing v8 --module --trace-opt index.js show that the optimization process for the functions commonRandom and commonRandomJS has been successfully completed. ... [completed optimizing 0x2b0e0824a769 <JSFunction commonRandom (s ...

Looking for guidance on how to initiate or halt React Native Moti animation when the state changes? I've been running into issues where my method appears to disrupt

While experimenting with the Moti animation, everything was working perfectly until I included the playbackState === State.Playing condition. Unfortunately, once I added it, the animation looped only once and then stopped repeating. I'm puzzled as to ...

Add a personalized header to the request sent from the <img/> element

Suppose you have a code snippet similar to this: <img src='images/whatever.jpj' width='' height=''/> Is there a way to set up custom headers for this specific request? I would be grateful for any guidance on this matt ...

Implementing Retrofit to pass API data into a Fragment

public class MainActivity extends AppCompatActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener { private GoogleApiClient googleApiClient; private LocationRequest loc ...

AngularJS encountered an error: myFunc has not been defined

I came across a code snippet similar to this one in a Github project, and it seems to be functioning properly. function myFunc($par1, $par2) { //some logic here } angular .module('myApp') .config(['$par1', '$par2' ...

Using jQuery to load content with a dynamic variable instead of specific element IDs

I am facing a minor jQuery issue. I am trying to load a specific area of an external HTML document into a div, but instead of loading just that particular area, the entire document is being loaded. Here's the code snippet for the trigger: $('a& ...

Ways to display the modal once the user initiates the action

Is there a way to delay loading my modal HTML codes until after the user clicks a button, rather than having them load automatically with the template? HTML <!-- Template Codes--> <button data-toggle="modal" data-target="#modal-content" type="bu ...

Trigger a function when the value of the file input field changes using ng-change

I'm attempting to trigger my upload() function when the file input changes, but I'm having trouble getting it to work. This is the HTML code: <input type="file" ng-model="image" ng-change="uploadImage()"> And here's the correspondin ...

Tips on redirecting the treeview menu using Material-UI 4

Currently, I am utilizing Material UI 4's Treeview component. However, I am struggling to figure out how to include a parameter that allows me to redirect to other pages when the user clicks on an item. In the past, I relied on a different method. Ch ...

Is it possible to create a loop for playing multiple videos stored in the raw folder using VideoView?

I am trying to accomplish the task of playing multiple videos stored in the raw folder on loop, one after another sequentially. However, I am facing an issue where I can only play one video in a loop using VideoView and unable to access the other ones. A ...

JavaScript CheckBox Color Change Not Functioning

Hello, I am currently experimenting with the checkAll function. When I click on the checkAll checkbox, it should select all rows and change their background color accordingly. Below is the JavaScript code I am using: function checkAll(objRef) { v ...

What are the best techniques for maintaining state in Xstate state machines within a React application?

I'm currently using a functioning cart state machine in reactjs to add items to the cart. However, I've noticed that when refreshing the page, the context is not persisted. As someone new to state machines, I would appreciate any assistance in fi ...

How can I ensure the Jquery datepicker functions correctly?

I've been attempting to create a jsp page with some Jquery functionalities. Unfortunately, despite my best efforts, I am unable to make it work. I have downloaded jquery1.7.1 and jquery-ui1.8.17 (non-mini), renamed them to jquery171.js and jquery-ui. ...

Determine whether the elements in an array are contained within a string as substrings

Is there a way to search through an array and return if its value is a substring of a string? An example in SQL would be: LIKE '%arr.value%' Let's say we have an array, arr = ['welcome', 'answer', 'question'], ...

Tips to prevent the return of undefined when a condition is not satisfied

I'm currently working on a react app and I have an array of objects (items) that I want to iterate over in order to display each object based on its index. I am using useState to set the index, which is updated when the user clicks a button. const ...

Posts are not visible on the site until the editor is updated when using wp_insert_post

Currently working on a plugin for a theme that includes multiple fields, utilizing both custom data and fields within the theme. An issue arises as the plugin is set up to create numerous posts using the wp_insert_post Function. However, only 1 to 3 post ...

Issue with php and ajax causing loop malfunction

I'm currently working on building a simple USD to pounds converter using PHP and AJAX. While I know it would be simpler with jQuery, unfortunately, the use of jQuery is not allowed for this assignment. The problem I'm facing is that when I run th ...