Search code examples
cordovaphonegap-pluginscordova-plugins

Plugin preferences in config.xml


I'm developing a plugin for cordova and I need to let user store some settings somewhere after installing the plugin. So I thought that the best place would be the config.xml file. As there are also some core plugins that does this (like StatusBar). This is ok on iOS but I could not find a way to access the values of config.xml file from android native code.

all I have in an andorid native code is access to the static Config instance but it does really return nothing about config values.

On iOS this is however possible to access any value of any key inside config file like what is done here: https://github.com/apache/cordova-plugin-statusbar/blob/master/src/ios/CDVStatusBar.m#L77

which actually accesses this dictionary populated with the values of config file here: https://github.com/apache/cordova-ios/blob/master/CordovaLib/Classes/CDVViewController.m#L36

is there another way to access same data on android too?


Solution

  • so I found the solution. on android all of the preferences tags are added as extras to the intent, so you can basically back data from your intent like this:

    cordova.getActivity().getIntent().getStringExtra("name-of-preference-tag");