Javatpoint Logo
Javatpoint Logo

Config.xml file

Config.xml can be defined as a global configuration file of the Cordova application, where we can change the configuration of our app. In the previous section, we have created our first Cordova application, where we set reverse domain and name. If you want to change these existing values, you can easily change them by using the config.xml file.

It is a platform-agnostic xml file that consists of all the necessary information required by the Cordova to convert the code in the www folder to the platform-specific installer. This file controls the Cordova behavior based on the W3C's packaged web apps. It also specifies the metadata of the application. It is a default file that is automatically created when creating any Cordova app.

This file can be edited either manually or using specific commands of Command Line Interface (CLI). We can add two configurations to this file, i.e., global and platform-specific.

The global configuration specifies the configuration that is common to all the devices, whereas the platform-specific configuration is specific to the platform.

The configurations are parsed to an app, and then the content is translated into a set of features. These features are responsible for generating the policy to access the native device APIs and show the app interaction with the web domains.

This file is available at the top-level directory of an app:


Config.xml file

Before version 3.3.1- 0.2.0, the config.xml file was present at app/www/config.xml.

When we build any app using the CLI, versions of the config.xml file are copied into various platforms/ subdirectories.

Configuration table of config.xml file:

The below table defines the elements used in the config.xml file:

Elements Description
Widget It defines the reverse domain value of an app that should be specified when creating the app.
Name It defines the name of an app.
Description It represents the description of an app.
Author It represents the contact information that can be shown within app-store listings.
Content It represents the starting page of an app at the top-level web assets directory. The default value is index.html that appears at the top-level www directory.
Plugin It is an additional feature for enhancing the capabilities of Cordova. It can be defined as a package of code that helps to communicate with the native platforms.
Access It is used to control access for a specific network domain. It has the default origin value *, which shows that the access is opened to any domain.
Engine It specifies the details about the platform, which is restored during the implementation.
allow-intent It is used for enabling the specific URLs to ask the app to open.
Hook It represents your custom script that is called by Cordova when a particular action occurs. It is useful for extending the default Cordova functionality.
Platform It represents a platform where we build our application.
resource-file It installs the resource file into the system.


The widget is the root element of the config.xml file. The widgets-config.xml file stores the information of widget definitions, widget attributes, page definitions, and default widget templates. We can edit the configuration settings of config.xml to perform several tasks. For example, if we want to enable the custom widgets, we can easily do that by defining the widget in the config.xml file. It consists of some attributes that are listed below:

Attributes(type) Only for platform Explanation
id(string) A required attribute that specifies the reverse domain identifier of an app.
version(string) A required attribute defines the full version number that are expressed in minor/major/patch notation.
It represents the alternative bundle id for the iOS platform. It overrides the id.
It represents the alternative version for iOS.
It represents the activity name in AndroidManifest.xml. Note that it can be set after the android platform is added.
It defines the alternative package name for android. It overrides the id.
It defines the package name for windows.
Default: Cordova.Example
It defines the alternative version for the windows.
It defines the alternative version for OS X.
xmlns:cdv(string) A required attribute that defines the Namespace prefix.
xmlns(string) A required attribute that defines the Namespace for config.xml file.

Preference: An element that is used to set various options as pairs of name/value attributes. The name of the preference is case-insensitive. Many preferences are specific to individual platforms. Some of the attributes of preference are listed below:

Attributes Type Explanation
Orientation String It allows you to lock the orientation. Due to this, it does not rotate in response to changes in orientation. The allowed values are default, landscape, and portrait. Its default value is the default.
EnableViewportScale Boolean If we set the value to true, it prevents the range of user scaling through a viewport meta tag. Its default value is false.
UIWebViewDeclarationSpeed String It is used for controlling the deceleration speed of momentum scrolling. Its default value is normal.
BackupWebStorage String The allowed values are none, local, and cloud. Its value is set to cloud to backup web storage data through iCloud.


If you want to use CLI to build an app, you must have to use the plugin commands to enable device APIs. Thus, the top-level config.xml file does not vary. Thereby, the element is not applied to the workflow. If you work directly in an SDK and use a source file of platform-specific config.xml, you must have to use the tag to enable device-level APIs and the external plugins.

Name: An attribute of a feature of string type that defines the name of the plugin to enable.

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA