Cordova saving a file within the www folder - javascript

I am currently creating a Cordova app to save files and read files. I ahve successfully managed to code it up so that it reads a file from the device (or creates it if it does not exist) and then write to that file.
The problem I am having is that it is saving the file to the root of the device. I added in a getDirectory method to create a new directory under the root where the file can sit and this is working but ideally I would like to save the file within the www folder of my Cordova app. Is this possible? Also is there any way of making sure the user is unable to write to this file?

The www folder is in readonly mode. You can't write anything in it.
Cordova plugin file documentation explain this.

Related

controlling mainBundle resource paths iOS development

I am trying to set up an ipad app that relies on using javascript for part of its functionality. I need to have the files in a folder named javascript to have some code I am using work properly.
I have created a symlink from my javascript files into the folder I set up and have included the files in the copy bundle resources in the appropriate build phase.
My issue is that under that section xcode says the files are in javascript/...
So in theory everything should be in the right folder. However, in my code I am using
[NSBundle mainBundle] pathForResource: pathName ofType:nil]]
and it returns nil when I set the path to the file in the file path and name listed in xCode.
Is there something I am not doing right to the app to have to proper file path names?
I am using the ipad simulator and xCode 5
For files that are in a subdirectory of your app bundle, you want to use the method pathsForResourcesOfType:inDirectory:

Creating basic apps with PhoneGap

I installed PhoneGap with nodejs, and I sent the create command to create a folder with the basic files needed for the first app. When I open the index.html file there is a script tag that points to a file called phonegap.js. The problem is that this does not exist in the folder, where is it? The app is running if built without that file or not?
That is my folder:
My object is to create a basic app working.
Thanks.
The file is created when you add a platform to your project (because its content is different for each platform)
For example, for an android project it should be in platforms/android/assets/www/phone gap.js.

Problems with public directory when deploying Node.js app with Heroku

I've been working on an app which will feature a Timelinejs (open source js library) element on the client side. I copied the Timelinejs library into my public/javascripts/ directory of my app. Then I linked it in my html header. When I serve my app up locally everything works fine with the timeline. However, I noticed that when I deployed my app to Heroku it wasn't loading my timeline. Using chrome js console I discovered that it didn't find my files in the public/Javascripts/Timelinejs folder. Using the Heroku run bash command I discovered that none of my Timelinejs files were present in the file structure, although an empty Timelinejs directory was present. Is there any command or configuration I need to specify to get these files to my Heroku deployment?
Heroku has a readonly file system. The directory where you can write are ./tmp or ./log. You can't write inside the public folder.
That's because of how they manage their dynos and the way to scale them. If you want to store something, use the ./tmp or, recommended, a s3 bucket. (as I presume 'tmp' stands for 'temporary' :D)
More info here: https://devcenter.heroku.com/articles/read-only-filesystem

Problems with adding multiple html files on Mosync

i'm new to Mosync and i'm trying to create an HTML5/Javascript project. The IDE generates a main.cpp file and an index.html file.
The main.cpp file contains a reference for the index.html file; i've already tried creating a new html file inside the same folder where the generated index.html file is and changed the reference in the main.cpp file to call the file that i've just created but it gives me an error that says the file cannot be found.
I've even tried removing all the code in the generate index.html file and running it and the results still shows all the deleted code from the index.html file.
My question would be how do i add multiple html files when creating a MoSync project?
It should work to do what you are doing, this could be a bug. Can you provide some details about which version of MoSync you are using, and which platform?
You should be able to have any html file in the folder LocalFiles in a MoSync project, and then just pass the file name to showPage in main.cpp, just as you are doing.
Perhaps the project is not rebuild properly? Try to right-click on the project in Eclipse, then select Rebuild. Are you on iOS or Android? How do you transfer the app to the device?
As Mikael mentioned also, I think it is an IDE bug, I tried refreshing/rebuilding the project and it worked fine. Sometimes eclipse does not detect file changes that come from other editors so it ignores them.

unable to add a js/css file to www folder in phonegap in xcode4

I've started coding in phonegap, I could get the helloworld project running, but the problem is that, I'm not able to add another js/css file to the www folder, and when I somehow add the file I'm not able to reference them. So can anybody suggest me a proper way to add a js/css file and how to reference it from the index.html file.
Thanks in advance

Categories

Resources