Reading a file (say a properties file) in phoneGap

570 views
Skip to first unread message

Kasun Lakpriya

unread,
Aug 28, 2011, 4:59:56 PM8/28/11
to phonegap
Hi Everyone,

I am developing an application using phoneGap and jQuery Mobile and I
want to have a properties file which have some key, value pairs. The
idea is, any one who needs to configure according to their
configurations will use one time changes to this file and build using
the phoneGap build to get the install-able file.

eg: this file might look like this:

url: http://myserverurl.com
instituteImage: imageurl

So once these configured here I want them to get them in JS code and
use them so the parties going to use the code I have written will only
need to do use this config file not the JS files. Any help would be
appreciated.

Thank you,
Kasun

Giacomo Balli

unread,
Aug 28, 2011, 5:14:13 PM8/28/11
to phonegap
you could use localStorage for settings made by the user.
If they're are preset, you could make your own plist.

Kasun Lakpriya

unread,
Aug 28, 2011, 5:48:26 PM8/28/11
to phonegap
Thank you.

Sorry if I have got you wrong. BTW I am not talking about end users of
the application. What I have developed is a (JS + CSS + HTML5) code
which is being used by number of institutes to build their own device
ready applications. So what I want is to add a file (say:
application.properties or something like this) with the package and
deliver to them they will just configure that file to have their
specific details like I mentioned above and *THEY* build the device
ready apps (.apk...) and deliver to end users.

So I need to read these properties in my application logic from this
property file? Sorry, if my explanation is again does not make sense.

thanks,
Kasun

Giacomo Balli

unread,
Aug 28, 2011, 11:03:06 PM8/28/11
to phonegap
could make it that there is a configuration js that all it has are the
values in json format.

Jesse MacFadyen

unread,
Aug 29, 2011, 1:14:26 AM8/29/11
to phon...@googlegroups.com
Yeah, just use an appSettings.js file, and define it something like this :

var appSettings = 
{
    url: "http://myserverurl.com",
    instituteImage:" imageurl",

   /*


}

--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en

For more info on PhoneGap or to download the code go to www.phonegap.com



--
--
Jesse MacFadyen
{
  blog:'blogs.nitobi.com/jesse',
  email:'jesse.m...@nitobi.com',
  company:
  {
    name:'Nitobi Software',
    site:'www.nitobi.com',
    phone:
    {
      office:'+1 (604) 685-9287',
      tollFree:'1-866-632-2777'
     }
  }
}

Jesse MacFadyen

unread,
Aug 29, 2011, 1:19:48 AM8/29/11
to phon...@googlegroups.com
Oops. accidentally hit send too soon.

Yeah, just use an appSettings.js file, and define it something like this :
var appSettings = 
{
    url: "http://myserverurl.com",
    instituteImage:" imageurl",

   /* more values here ... */


}

Then include it from any page that needs it via a script tag, and simply use it at run-time in your code.

var url = appSettings.url;
// do something with the values ...

About 8 years ago I made an NHL hockey pool website using this a js file as my database, not recommended ... but using for config values is a great idea!

Cheers,
  Jesse 

Kasun Lakpriya

unread,
Aug 29, 2011, 2:35:41 AM8/29/11
to phonegap
Thank you Giacomo for the hint and thanks Jesse for the example it
totally make sense and that is what I really wanted. :)

cheers,
Kasun

On Aug 29, 10:19 am, Jesse MacFadyen <jesse.macfad...@nitobi.com>
wrote:
> >   email:'jesse.macfad...@nitobi.com',
> >   company:
> >   {
> >     name:'Nitobi Software',
> >     site:'www.nitobi.com',
> >     phone:
> >     {
> >       office:'+1 (604) 685-9287',
> >       tollFree:'1-866-632-2777'
> >      }
> >   }
> > }
>
> --
> --
> Jesse MacFadyen
> {
>   blog:'blogs.nitobi.com/jesse',
>   email:'jesse.macfad...@nitobi.com',
Reply all
Reply to author
Forward
0 new messages