Adding preferences to phonegap build app

In this tutorial I will talk about what preferences are and how to use them in a phonegap build app. Preferences allow us to configure our app, there are various configurations that can be set which we will take a look at in this post. Preferences can be set either for all the platforms you wish to build for or they can be set separately for individual platforms.

Preferences need to be added to the config.xml file using the <preference> tag. Let’s take a look at an example, suppose we want to set the orientation of our phonagap app to lock at either landscape or portrait we can set the following preference

We can set our app to go full-screen, this will hide the top bar which displays the battery and clock , this can be done as follows

Types of preferences

There are basically two types of preferences

  1. Multi platform
  2. Platform specific

Multi platform preferences can be used as shown above by just using the <preference> tag. These type of preferences are common for all platforms and are applied uniformly across all operating systems.

Platform specific preferences you need to wrap theĀ  <preference> tag with the <platform> tag. The following example shows how the orientation of the same app can be set depending upon the platform


A very important thing to not here is that not all preferences will be supported by each platform i.e, a preference on android may not be available for iOS hence if you try to add that preference and build for iOS it will give you a build error on the phonegap build dashboard.

To check what preferences are available you can check out the phonegap build docs here.

Full example:

In this full example I will be working with the config.xml file that we have been using thus far in the course and I will add a few preferences to it. So the final result is as follows

As shown above we are setting the preferences like orientation, full-screen, etc. But the thing that I want you to take note off is the android-minSdkVersion preference which will build our app for android API level 16 which is known as Android Jellybean.

Here I have set some preferences which will apply to all platform also I have set some platform specific preferences inside the <platform> tag.



Preferences can do a lot form configuring which version for the operating system to build for to what screen orientation to set for you app.

The purpose of this tutorial was to introduce you to preference and how to set them. As mentioned in the post not all preferences are not universal and apply to all operating systems. You should read the documentation to determine which ones you need for your app.

Watch Video Tutorial Here:


Full Course Curriculum : Click here


Leave Me Your Questions And Feedback

Getting your feedback inspires me the most so hit me up in the comments here or on the comments section on my YouTube Channel or on twitter @uncutAcademy
Consider Subscribing / Donating
Subscribe To Mailing List
If my site was helpful to you, then please consider donating via paypal:
Prantik Vaghela

Prantik Vaghela (uncutAcademy)

Hi my name is Prantik Vaghela. I have done my Bachelors and Masters in Computer Science and am a web developer and now a Tutor through my blog. :-)