I am having trouble reading the www/config.xml file from Android device. I tried two different approaches. First, I tried using the $http service which was recommended in another thread to do. When that did not work I then tried to use the Cordova file plugin. The reason I am doing this is to try to get the version number from the www/config.xml file in the app. Below are both approaches:
-
$http.get()
url = ‘file:///android_asset/www/config.xml’
$http.get(url)
.then ((data) ->
versionNumber = data.data.match(/<widget\s.*?\sversion=’"[’"]/)
verNum = versionNumber[1]
), (err) ->
# {“data”: null, “status”: 0, …}
alert JSON.stringify err -
Cordova file plugin
if ionic.Platform.isAndroid()
path = 'file:///android_asset/www/'
file = ‘config.xml’
$cordovaFile.readAsText(path, file)
.then ((data) ->
alert JSON.stringify data
return
), (error) ->
# I alert { code: 5 } which is an ENCODING_ERR
alert JSON.stringify error