Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9130653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:59:59+00:00 2026-06-17T07:59:59+00:00

I’m trying to create a PhoneGap application for Android and iOS. So far I’ve

  • 0

I’m trying to create a PhoneGap application for Android and iOS.

So far I’ve been succeeding to the extent that I’ve been able to access the LocalFileSystem on Android 2.2 and up.

On iOS (5 and 6), I’ve had no such luck unfortunately.

The FileReader and FileWriter examples fail to work as well.

I’ve spent some time debugging this using jsconsole.com and as far as I can tell window.requestFileSystem and window.webkitRequestFileSystem are both undefined.
Which would explain why I have issues with the file system.

I’m using Cordova 2.2.0 and XCode 4.5 for the iOS part.

Both the example and my own code is working on Android.

If any of you have any advice I’d really appreciate the positive effect it will have on my mental health!

Edit:
index.html:

 <!DOCTYPE html>
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="format-detection" content="telephone=no" />
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
        <title>Hello World</title>
    </head>
    <body>
        <div class="app">
          <a href="javascript:myfs.clicked()">click!</a>
          
        </div>
        <script type="text/javascript" src="cordova-2.2.0.js"></script>
        <script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
    <script src="http://jsconsole.com/remote.js?secret-debug-key"></script>
        
        <script type="text/javascript" src="js/filesystem.js"></script>
        <script type="text/javascript">
          var myfs;
          document.addEventListener('deviceready', function() {
          myfs = new FS();
          myfs.initializeFileSystem();
          
});


        </script>
    </body>
</html>

filesystem.js:

var FS = (function() 
          {
              var self = {};
              
              self.initializeFileSystem = function() 
              {
                  window.requestFileSystem = window.webkitRequestFileSystem || window.requestFileSystem;
                  window.requestFileSystem(1, 0, self.gotFS, self.fail);
              };
              self.gotFS = function (fileSystem)
              {
                  window.rootFS = fileSystem.root;
                  //create our cache directory if it does not exist
                  var entry = fileSystem.root;
                  entry.getDirectory("tempdirectory", {create: true, exclusive: false}, function() {console.log("directory already present or created");}, function(error) {console.log("Error creating directory " + error.code);});                  
                  
              };

              self.fail = function()
              {
                  console.log("requestFileSystem failed");
              };

              self.downloadImage = function(url, fileName, callback)
              {
                  var ft = new FileTransfer();
                  var filename = fileName;
                  var callback = callback;
                  ft.download(
                      url,
                      window.rootFS.fullPath + "/" + filename,
                      function(entry)
                      {
                          if(callback!= undefined)
                          {
                              callback(entry);
                          }
                      },
                      function(error)
                      {
                          console.log("download error: " + error.code);
                      }
                  );
              };

              self.clicked = function()
              {
                  //random test URL
                  var url = "http://www.embeddedpeople.dk/_/rsrc/1301663383918/home/ydelser/konsulentydelser/test/test.png?height=400&width=350";
                  self.downloadImage(url, "test.png", function(){console.log("download succesful");$('body').append('<img src="file:///data/data/dk.attention8.filesystem/test.png" />');});
                  return false;
              };
              return self;

          }

         );

This works on Android, after the click has been made, the file is downloaded and an img tag containing a reference to the path of the downloaded image should be inserted in the DOM.
I’m aware that this path isn’t valid on iOS nor the correct one on a device with an SDcard, but the issue is occuring before this img tag is added.
This image should show that the javascript code works in Android ( taken of the Android Emulator ). Screenshot

If you need further clarification or have questions I’ll provide them as fast as I can.
Thank you for your time!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:00:00+00:00Added an answer on June 17, 2026 at 8:00 am

    I’ve finally resolved this issue.

    I’ve had a common “www” folder that I’d transfer from my Android to my iOS project.

    I’ve naively overwritten the entire www folder, and this has been causing the problem.

    The cordova.js file in the root of the www folder is platform specific, and I had thusly used the Android cordova.js file in my iOS project, which obviously wasn’t working.

    Thank you to fmertz on #phonegap for pointing me in the right direction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to understand how to use SyndicationItem to display feed which is
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.