I have the name of my application in strings.xml
the folder res/values
:
<string name="app_name">Liturgia+</string>
I would like to change that value, adding the current version of the app. Assuming the current version is 1.3
, I would like something like this:
Liturgia+ (v. 1.3)
My question is if it would be possible to automatically get the current value of the version inside an xml resource , so that the value is updated only when the version changes.
Inside you
build.gradle
can define theversionName
, which is a String indicating the version:You can also define these values within your file
AndroidManifest.xml
just remember that the configuration of the
build.gradle
always overrides the one of the fileAndroidManifest.xml
Given the above, you can get the value of
versionName
in this way :another way is simply (requires the project to be built):
The String value of
versionName
can be concatenated to the name of your application.You can even define as
versionName
the valueLiturgia+ (v. 1.3)
, example:I think it is not possible to do that, what you can do is get the versionName from gradle using code, and then concatenate in code but not in XML
To get the versionName you use the following code: