Reference a local file in my phonegap android app - android

I am trying to reference a local html file in my phonegap android app. I am seeing where something like www/myapp_name/somefile.html does not work, is there a away to do this?

You don't have to add the www. If you structure is as follow
/myprojectname/www/index.html
/myprojectname/www/contact.html
And you wish to make a link from index.html to contact.html you can juse use
contact.html
Just use the relative path. Don't add a / up front.

Related

Cordova/Phonegap - Where do I put a data file I want to read?

I've been driving myself crazy trying to find the answer to a seemingly easy question.
I am trying to create my first app using Cordova. I want to bundle a text file with my app that can be read when the app starts up.
Where do I put this file?
dataDirectory seems like a good place, but where is it? Documentation says /data/data/<app-id>/files but where are those data directories? Do I create them?
Update 1: Ok, I think I've figured out that dataDirectory should be pretty much just where the path says it should be, at the root of the file system. But the directory doesn't appear to be created automatically and I don't know how to package a file - a JSON file, for instance - and place it in that directory.
Essentially you do not need to create these directories. Those are created once your app is installed by the Android itself.
A typical way to get this done would be that you could first off add those files in your app's assets directory and then at runtime you can copy those file wherever you want.
There is a repository on Githup which provide a similar functionality.

Cntrl + click not working in Android studio

I am new to Android Studio.I like the IDE very much,it has got some nice set of features and has a rich look and feel, however I have some issues with the IDE. I recently created a Cordova application in android studio.I created an HTML file called index.html under assests/www folder.I included my jquery-1.11.3.min.js inside index.html file.I have the habit of checking whether the file jquery-1.11.3.min.js has been correctly included inside HTML file.In eclipse I use cntrl +click to check whether the js file path given is right.But when I use the same thing in Android studio,even if the path is right,it is showing like 'Cannot find declaration to go to'.The screenshot for the same is given below.
Can anyone suggest a solution for this situation.

Access internal files after built - Cordova

I am wondering if is possible accessing the internal files of an app after build with cordova plugin.
My project is based on Android and here are my files:
index.html
html:
- remove.html
js
css
So, after build the app, I want to access with some option within the app the remove.html and remove it.
I find that the FILE plugin of cordova is useful for files inside the device but not the app.
Please anyone has any idea?
we do not have modification access to the location where apk's internal files are saved. Since your remove.html is part of your app apk, we cannot just remove it.
You can take the same approach taken by sqlite raw database file. When your app is started or run for the very first time, copy your file (remove.html) to data folder where you can modify/delete it. Make sure your app only uses this new path everywhere.
Take a look at copyDatabaseFromAssets function in this code for a sample on how do this. Since you will have modification access, you can delete or modify this file as needed.

assets folder wasn't created in android app whan using phonegap

I try to create a mobile app using stand-alone phonegap. When I use the following coding
D:\phonegap-2.8.0\lib\android\bin>create \foldername myapp.package.com proname
there is no assets folder created in the project folder. What can be the reason for that?
It doesn't get created automatically. You will have to create it on your own. Use this tutorial to make a move.

Images "missing" in emulator, after build

I have built an Android App, using a jQuery Mobile index.html file "wrapped" inside Java using the Android SDK on Eclipse.
However, although the images appear OK within the Dreamweaver "Live" view for jQuery mobile,
they don't appear in the emulator in Android SDK after successful build.
I have added the image files within an image folder in the RES/mpdi folder of the project, and within the index.html file they are referenced as images/"...png" etc
Should I have changed the path in any way in the index.html file?
Also, they are 290x381 pixels - should I have had a different size for the AVD?
Thanks in advance!
David
I will assume you are using something like phonegap
phonegap has a whitelist that tells the app which URLs it's allowed to access. You can also add a * to it, as described http://www.anujgakhar.com/2011/11/22/phonegap-gotcha-error-whitelist-rejection/ found in in the /res/xml/phonegap.xml file

Categories

Resources